users@glassfish.java.net

Latest version of Toplink Essentials problem with bidirectional one-many ?

From: <glassfish_at_javadesktop.org>
Date: Thu, 04 Oct 2007 06:11:58 PDT

I can run my app happily on OC4J (Oracle App Server) 10.1.3.1 but when I migrate to either OC4J 10.1.3.3 or Glassfish v2 b58 I get problems with the JPA generating incorrect SQL for inserts for classes with bidirectional one-to-many relations. To illustrate, my tables and classes are as attached - I have tables and classes generated by JDeveloper as Testparent and Test and then reverse engineered through JDeveloper and added annotations in orm.xm (to avoid losing my annotations if I put them into the java file itselfl.

The stack trace is as follows - something strange is going on as the runtime thinks I have one table called TESTPARENT_TESTCHILD whereas I actually have 2 tables TESTPARENT and TESTCHILD. Could be that I've got the relationship wrong in my annotations ?:

Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-00942: table or view does not exist

Error Code: 942
Call: INSERT INTO TESTPARENT_TESTCHILD (ID, ID2, Testparent_ID) VALUES (?, ?, ?)
        bind => [1, 1, 1]
Query: DataModifyQuery()
        at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:311)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:654)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:703)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:492)
        at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:452)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeCall(AbstractSession.java:690)
        at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
        at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:214)
        at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:257)
        at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:237)
        at oracle.toplink.essentials.internal.queryframework.StatementQueryMechanism.executeNoSelect(StatementQueryMechanism.java:144)
        at oracle.toplink.essentials.queryframework.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:86)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:555)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
        at oracle.toplink.essentials.mappings.ManyToManyMapping.insertIntoRelationTable(ManyToManyMapping.java:752)
        at oracle.toplink.essentials.mappings.ManyToManyMapping.performDataModificationEvent(ManyToManyMapping.java:902)
[Message sent by forum member 'richliv' (richliv)]

http://forums.java.net/jive/thread.jspa?messageID=238444