| Summary: | NullpointerException occurs on DatabaseObjectDefinition.getFullName(...) when specifying the @Index annotation in an Entity class | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Aaron Dockter <adockter> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | NEW --- | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | CC: | tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
Apologies... the first line in my bug description should read: Found a bug in the EntityAccessor.java class where one of the conditional statements, that sets the qualifier for an Index, is checking for null against "getDescriptor().getDefaultSchema()", but setting the qualifier to the value of "indexMetadata.getSchema()", which had already been determined as null. Thanks so much! Note: I downloaded the latest source code for 2.2.1 (eclipselink-src-2.2.1.v20110325-r9169) and still see the problem. Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: eclipselink-plugins-2.2.0.v20110202-r8913 Found a bug in the EntityAccessor.java class where one of the conditional statement that sets the qualifier for an Index is checking for null against "getDescriptor().getDefaultSchema()", but setting the qualifier to "getDescriptor().getDefaultSchema()", which had already been determined as null. This is preventing indexes from being created properly while interpreting the metadata. As a result a simple composite index on an Entity cannot be created. For Example: @Entity @Indexes({ @Index(name="IDX_COG_POR_ATYPE", columnNames={"CALLOUTGUID","PRIORITYORDER","ACTIONTYPE"}, unique=true), @Index(name="IDX_COGUID", columnNames={"CALLOUTGUID","PRIORITYORDER","ACTIONTYPE"}, unique=true)}) public class Task implements Serializable { /** * Default id */ private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Column(name="BUSINESSSERVICEID", nullable=false) private Long businessServiceId; @Index @Column(name="CALLOUTGUID", nullable=false) private Long calloutGUID; @Index @Column(name="PRIORITYORDER", nullable=false) private Integer priorityOrder; @Index @Column(name="ACTIONTYPE", length=100, nullable=false) private String actionType; ... } As the tables are being created, you will experience the following error: Query: DataModifyQuery(sql="DROP TABLE NOVELL.TASK") [EL Severe]: 2011-03-29 16:18:11.114--ServerSession(505066727)--Thread(Thread[Karaf Shell Console Thread,5,main])--java.lang.NullP ointerException at org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition.getFullName(DatabaseObjectDefinition.java:111) at org.eclipse.persistence.tools.schemaframework.IndexDefinition.buildCreationWriter(IndexDefinition.java:71) at org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition.createOnDatabase(DatabaseObjectDefinition.java:8 1) at org.eclipse.persistence.tools.schemaframework.TableDefinition.createIndexes(TableDefinition.java:802) at org.eclipse.persistence.tools.schemaframework.TableDefinition.postCreateObject(TableDefinition.java:1042) at org.eclipse.persistence.tools.schemaframework.SchemaManager.createObject(SchemaManager.java:196) at org.eclipse.persistence.tools.schemaframework.SchemaManager.replaceObject(SchemaManager.java:892) at org.eclipse.persistence.tools.schemaframework.TableCreator.replaceTablesAndConstraints(TableCreator.java:297) at org.eclipse.persistence.tools.schemaframework.TableCreator.replaceTables(TableCreator.java:260) at org.eclipse.persistence.tools.schemaframework.SchemaManager.replaceDefaultTables(SchemaManager.java:954) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.createOrReplaceDefaultTables(EntityManagerFactoryProv ider.java:90) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.writeDDLToDatabase(EntityManagerFactoryProvider.java: 357) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.generateDDL(EntityManagerFactoryProvider.java:127) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:399) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:185) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:242 ) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:230) RESOLUTION: In EntityAccessor.java the "processIndexes()" method, change else if ((getDescriptor().getDefaultSchema() != null) && (getDescriptor().getDefaultSchema().length() != 0)) { indexDefinition.setQualifier(indexMetadata.getSchema()); } to else if ((getDescriptor().getDefaultSchema() != null) && (getDescriptor().getDefaultSchema().length() != 0)) { indexDefinition.setQualifier(getDescriptor().getDefaultSchema()); } ~line 936 in EntityAccessor.java I might also suggest changing the DatabasesObjectDefinition.java "getFullName()" method to handle a null qualifier: public String getFullName() { if (getQualifier() == null || (getQualifier() != null && getQualifier().equals(""))) { return getName(); } else { return getQualifier() + "." + getName(); } } ~line 110 in DatabaseObjectDefinition.java Reproducible: Always Steps to Reproduce: 1. Create an entity class with some composite index as per: http://wiki.eclipse.org/EclipseLink/Examples/JPA/Indexes 2. Create an osgi bundle and start the module 3. Kick off the table creation and see the NullPointerException in DatabaseObjectDefinition.getFullName()