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.
This is the cmp order schema from the J2EE 1.4 tutorial. Trying to generate EJB 3 entities from it causes several exceptions: 1) When trying to "connect", when choosing it in the data source combo, there are NNModelBuilder exceptions 2) During generation, there are other exceptions I'll attach the dbschema file and my IDE log file (started with a clean user dir, so hopefully all exceptions for this issue).
Created attachment 29457 [details] dbschema file
Created attachment 29458 [details] IDE log
The NNModelBuilder exceptions are filed as issue 73926.
INFORMATIONAL *********** Exception occurred ************ at 12:57 PM on Apr 28, 2006 javax.jmi.reflect.InvalidObjectException: Object with MOFID 02300119-D6F1-11DA-ABD9-E6EF4CBCAA77:0000000000000EDC no longer exists, class: org.netbeans.jmi.javamodel.Resource$Impl at org.netbeans.mdr.handlers.BaseObjectHandler._getDelegate(BaseObjectHandler.java:359) at org.netbeans.mdr.handlers.AttrImmutCollWrapper.getInnerCollection(AttrImmutCollWrapper.java:61) at org.netbeans.mdr.handlers.AttrImmutCollWrapper.toArray(AttrImmutCollWrapper.java:137) at org.netbeans.modules.javacore.jmiimpl.javamodel.LightAttrList.toArray(LightAttrList.java:305) at java.util.ArrayList.addAll(ArrayList.java:473) at org.netbeans.modules.javacore.jmiimpl.javamodel.ResourceImpl.getInitedChildren(ResourceImpl.java:248) at org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.rollback(MetadataElement.java:184) at org.netbeans.modules.javacore.jmiimpl.javamodel.ResourceImpl.rollbackChanges(ResourceImpl.java:778) at org.netbeans.modules.javacore.ExclusiveMutex.notifyElements(ExclusiveMutex.java:502) [catch] at org.netbeans.modules.javacore.ExclusiveMutex.leave(ExclusiveMutex.java:356) at org.netbeans.mdr.NBMDRepositoryImpl.endTrans(NBMDRepositoryImpl.java:249) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.JavaPersistenceGenerator.generateBeans(JavaPersistenceGenerator.java:423) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard.createBeans(RelatedCMPWizard.java:241) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard.access$100(RelatedCMPWizard.java:42) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard$2.run(RelatedCMPWizard.java:191) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:493) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:926)
Isn't it real cause of problem NPE from JavaPersistenceGenerator? I didn't investigate it in detail, but from my first observation it seems there is NPE thrown in your code. Java model then is trying to do rollback all changes which throws exception you reported. (Not sure yet if it does or doesn't matter but definitely nothing will be generated from such a transaction.) java.lang.NullPointerException at org.netbeans.modules.j2ee.persistence.wizard.fromdb.JavaPersistenceGenerator.generateBeans(JavaPersistenceGenerator.java:323) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard.createBeans(RelatedCMPWizard.java:216) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard.access$100(RelatedCMPWizard.java:38) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard$2.run(RelatedCMPWizard.java:176) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:493) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:926)
I did have code in my ws testing for the NPE a while ago, but that was before you fixed the other bug. Now with that fix, the generation occurs with only the NNModelBuilder exceptions, so I guess this is not a JMI problem. The problem is for the field in Part.java: @javax.persistence.ManyToOne private Part part1; There is no column mapping in dbMappings for this field. What should be generated is (also): @JoinColumns({ @JoinColumn(name="BOMPARTNUMBER", referencedColumnName="PARTNUMBER"), @JoinColumn(name="BOMREVISION", referencedColumnName="REVISION") }) Pavel B, do you know what the problem might be?
I see following exceptions except the INFORMATIONAL ones from NNModelBuilder: [org.netbeans.javacore] INFORMATIONAL *********** Exception occurred ************ at 1:19 PM on May 2, 2006 java.lang.Exception: rollback!!! at org.netbeans.modules.javacore.ExclusiveMutex.leave(ExclusiveMutex.java:340) at org.netbeans.mdr.NBMDRepositoryImpl.endTrans(NBMDRepositoryImpl.java:249) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.JavaPersistenceGenerator.generat eBeans(JavaPersistenceGenerator.java:423) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard.createBeans(Rel atedCMPWizard.java:241) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard.access$100(Rela tedCMPWizard.java:42) at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard$2.run(RelatedCM PWizard.java:191) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:493) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:926) INFORMATIONAL *********** Exception occurred ************ at 1:19 PM on May 2, 2006 javax.jmi.reflect.InvalidObjectException: Object with MOFID 924C262A-D9CB-11DA-A6E4-18EF5596AA7 7:0000000000000BF8 no longer exists, class: org.netbeans.jmi.javamodel.Resource$Impl at org.netbeans.mdr.handlers.BaseObjectHandler._getDelegate(BaseObjectHandler.java:359) at org.netbeans.mdr.handlers.AttrImmutCollWrapper.getInnerCollection(AttrImmutCollWrapp er.java:61) at org.netbeans.mdr.handlers.AttrImmutCollWrapper.toArray(AttrImmutCollWrapper.java:137 ) ... Those from NNModelBuilder (java.lang.IllegalArgumentException: The bean property doesn't exist!) are harmless from the generation point of view AFAIK. They cause that the s2b tree is not properly filled with data gotten from the annotations in the generated sources. If the missing model data is the P1 problem then please confirm and describe why. If not, with respect that the problem with NNMB is filled as Issue #75033, I do not see any reason why this issue is assigned to me, or even why it is P1?? (the sources seems to be generated properly). Please elaborate what is wrong in particullar ...
OK, let's deal with the exception ending in BaseObjectHandler._getDelegate in this issue. Reassigning to me for now. The cause of the issue is that the PART table references itself and two RelationshipRole-s with the same field name ("part") are added to the EntityClass for this table. The algorithm which makes the field names unique then changes one of the field name to "part1", and of course there aren't any mappings for that field.
I'm little bit confused by comments from Marek and Andrei. Rollback exception "java.lang.Exception: rollback!!!" is result of some exception in try block, variable rollback in PersistenceJavaGenerator:413 was not set to false at the end of try block, that is the reason nothing should be generated from such a transaction. Rochelle wrote that NPE is not thrown in current build so I expect there is neither "rollback" exception nor "InvalidObjectException" at the end. Or was the InvalidObjectException thrown during commit? Is there something what I did not understand?
No, there is a rollback. A NPE is thrown at JavaPersistenceGenerator:324 (JavaPersistenceGenerator.java rev 1.1.2.2.2.21) and it causes the rollback (thank you for pointing this out BTW!). The NPE is caused by the fact that there are no mappings for a field in a RelationshipRole, but the code in JPG doesn't expect that.
What I said was the NPE didn't occur in my workspace - the fix wasn't in the build until now: In beta: Checking in src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/JavaPersistenceGenerator.java; /cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/JavaPersistenceGenerator.java,v <-- JavaPersistenceGenerator.java new revision: 1.1.2.2.2.21.2.1; previous revision: 1.1.2.2.2.21 done
In release55: Checking in src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/JavaPersistenceGenerator.java; /cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/JavaPersistenceGenerator.java,v <-- JavaPersistenceGenerator.java new revision: 1.1.2.2.2.22; previous revision: 1.1.2.2.2.21 done
Downgrading to P3 now that the impact is not failure but instead compilable but incomplete classes.
*** Issue 73912 has been marked as a duplicate of this issue. ***
Rochelle, can you please have a look at this? The mappings for CMP entity beans are generated correctly from the same model, so it should work from entity classes too. It seems JavaPersistenceGenerator interprets the model in a different (wrong) way. I can't look at how the mapping is done for entity beans because it is in persistence-tool-support.jar and I don't have a good understanding of that code anyway. Please reassign back to me if it can't be fixed without making a change in the mapping model. Thanks.
Andrei, I remember before beta you had a fix for the missing 1:1 mapping info and that it was just too risky to add to beta. Why not just test and commit that fix on the release55 branch now?
Sorry, I meant self referencing, not 1:1
Because the fix seems superfluous to me. It added some information to the model which doesn't seem to be necessary (since CMP entity beans are mapped correctly). If CmpGenerator can live with just what is now in the model, why couldn't JavaPersistenceGenerator too?
I just checked in the persistence-tool-support.jar code and the way it's done there is to map the inverse field when it's found, because in 1.4 all relationship mapping is 2-way. Probably what happens is that in 1.4, the other field which has a column mapping set in the cmpMapping model is found, then both sides of the relationship mapping is set. When the one with null for the column mapping is found, it doesn't matter because its mapping is taken care of by the inverse field. But in JavaEE 5, this is not the case - we don't set up inverses. Does that help?
This seems to have been fixed by Rochelle's fix of issue 75807. Now the following mapping is generated for a self-referencing table PERSON (ID, NAME_SURNAME, DIRECTOR, MANAGER) where DIRECTOR -> ID and MANAGER -> ID: -----<%---- @Id @Column(name = "ID", nullable = false) private Integer id; @Column(name = "NAME_SURNAME") private String nameSurname; @OneToMany(mappedBy = "director") private java.util.Collection <entity.Person> personCollection; @JoinColumn(name = "DIRECTOR") @ManyToOne private Person director; @OneToMany(mappedBy = "manager") private java.util.Collection <entity.Person> personCollection1; @JoinColumn(name = "MANAGER") @ManyToOne private Person manager; -----<%---- Looks correct to me.
Removing the hotfix because it is not needed anymore and if something goes wrong again a NPE is more visible than some annotations not being generated. Checking in src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/JavaPersistenceGenerator.java; /cvs/j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/Attic/JavaPersistenceGenerator.java,v <-- JavaPersistenceGenerator.java new revision: 1.1.2.2.2.32; previous revision: 1.1.2.2.2.31 done