This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 101378 - EntitiesFromDBGenerator doesn't work
Summary: EntitiesFromDBGenerator doesn't work
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Erno Mononen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-17 15:01 UTC by Jan Stola
Modified: 2007-04-17 17:59 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Stola 2007-04-17 15:01:02 UTC
EntitiesFromDBGenerator sometimes/usually doesn't work. This makes the JPA 
support in form module unusable. It seems that the generator have a problem 
with tables that have a foreign key. Try, for example, to generate entity class 
for CUSTOMER table in the sample database of GlassFish. The following exception 
is thrown:

java.lang.NullPointerException
  at org.n.m.dbschema.jdbcimpl.TableElementImpl.initFKs
     (TableElementImpl.java:463)
  at org.n.m.dbschema.jdbcimpl.TableElementImpl.initKeys
     (TableElementImpl.java:395)
  at org.n.m.dbschema.jdbcimpl.SchemaElementImpl.initTables
     (SchemaElementImpl.java:419)
  at org.n.m.dbschema.jdbcimpl.SchemaElementImpl.initTables
     (SchemaElementImpl.java:289)
  at org.n.m.j2ee.persistence.api.entity.generator.EntitiesFromDBGenerator
     .getSchemaElement(EntitiesFromDBGenerator.java:173)
  at org.n.m.j2ee.persistence.api.entity.generator.EntitiesFromDBGenerator
     .getTableClosure(EntitiesFromDBGenerator.java:146)
  at org.n.m.j2ee.persistence.api.entity.generator.EntitiesFromDBGenerator
     .generate(EntitiesFromDBGenerator.java:121)
  ...
Comment 1 Erno Mononen 2007-04-17 17:59:20 UTC
Should be fixed in trunk now. The problem was indeed related to tables with 
foreign keys, the NPE was thrown when trying to generate an entity for a table 
with a foreign key reference to another table that wasn't provided to the 
generator. Please note that the fix is in the db/model module. 

Checking in TableElementImpl.java;
/cvs/db/model/src/org/netbeans/modules/dbschema/jdbcimpl/
TableElementImpl.java,v  <--  TableElementImpl.java
new revision: 1.5; previous revision: 1.4
done
Checking in SchemaElementImpl.java;
/cvs/db/model/src/org/netbeans/modules/dbschema/jdbcimpl/
SchemaElementImpl.java,v  <--  SchemaElementImpl.java
new revision: 1.7; previous revision: 1.6
done