Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] A Join table with additional columns. Eclipselink 2.0.1

Hello,

Not sure if this is the cause of the exception, but the ZenCategory class is using the OneToMany(mappedBy="category") but also defining a joincolumn which it shouldn't.  The mappedby tells it to use the column defined in the category mapping on the ZenCategoryDescription.  

The exception is occuring due to the default column name being used for the ZenCategoryDescription category mapping, but I'm not sure why it wouldn't pick up the PrimaryKeyJoinColumn definition.  If removing the join column annotation on the ZenCategory class doesn't work, try using just a JoinColumn and setting it to be updatable/insertable=false.  If you are able to use JPA2.0 annotations, use the @MapsId(name="categoryId") annotation instead of a joincolumn.  

Best Regards,
Chris
----- Original Message -----
From: chris-m@xxxxxxx
To: eclipselink-users@xxxxxxxxxxx
Sent: Saturday, May 22, 2010 2:51:51 PM GMT -05:00 US/Canada Eastern
Subject: Re: [eclipselink-users] A Join table with additional columns. Eclipselink 2.0.1

Den 18.05.2010 20:43, skrev James Sutherland:
>
> Could you include the code you have so far, and the exception and stack that
> you are currently getting.

Sorry for the long response time, had a final exam on friday.
I've messed back and forth with this code so I've probably added some 
more "undocumented features".

http://pastebin.com/L7MQLhzv - ZenCategory
http://pastebin.com/7Ww6fNAT - ZenLanguage
http://pastebin.com/75KH6r7F - ZenCategoryDescription
http://pastebin.com/DRf5t9HJ - ZenCategoryDescriptionLanguageId

Stacktrace:

[EL Warning]: 2010-05-22 
20:40:27.686--ServerSession(861445718)--Exception [EclipseLink-4002] 
(Eclipse Persistence Services - 2.0.1.v20100213-r6600): 
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: 
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown 
column 'CATEGORY_categories_id' in 'field list'
Exception in thread "main" Local Exception Stack:
Error Code: 1054
Call: SELECT categories_id, language_id, categories_description, 
categories_name, CATEGORY_categories_id FROM zen_categories_description 
WHERE (CATEGORY_categories_id = ?)
         bind => [22]
Query: ReadAllQuery(name="descriptions" 
referenceClass=ZenCategoryDescription sql="SELECT categories_id, 
language_id, categories_description, categories_name, 
CATEGORY_categories_id FROM zen_categories_description WHERE 
(CATEGORY_categories_id = ?)")
Exception [EclipseLink-4002] (Eclipse Persistence Services - 
2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: 
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown 
column 'CATEGORY_categories_id' in 'field list'
Error Code: 1054
Call: SELECT categories_id, language_id, categories_description, 
categories_name, CATEGORY_categories_id FROM zen_categories_description 
WHERE (CATEGORY_categories_id = ?)
         bind => [22]
Query: ReadAllQuery(name="descriptions" 
referenceClass=ZenCategoryDescription sql="SELECT categories_id, 
language_id, categories_description, categories_name, 
CATEGORY_categories_id FROM zen_categories_description WHERE 
(CATEGORY_categories_id = ?)")
         at 
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
         at 
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:687)
         at 
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:530)
         at 
org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:529)
         at 
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:205)
         at 
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:191)
         at 
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:262)
         at 
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:618)
         at 
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2537)
         at 
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2496)
         at 
org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:455)
         at 
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997)
         at 
org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:675)
         at 
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
         at 
org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:432)
         at 
org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2322)
         at 
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)
         at 
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)
         at 
org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:85)
         at 
org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:75)
         at 
org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
         at 
org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:161)
         at 
org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:230)
         at 
org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
         at 
org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:237)
         at 
org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:397)
         at 
org.eclipse.persistence.indirection.IndirectList.size(IndirectList.java:726)
         at 
com.superheltfabrikken.dbaccess.zencart.ZenCategory.getName(ZenCategory.java:30)
         at cincusjpaexperimenting.Main.main(Main.java:32)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
Unknown column 'CATEGORY_categories_id' in 'field list'
         at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
         at com.mysql.jdbc.Util.getInstance(Util.java:381)
         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3536)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1957)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2107)
         at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648)
         at 
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2086)
         at 
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2237)
         at 
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:892)
         at 
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:602)
         ... 27 more
Java Result: 1

-- 
Regards
Christian Michelsen
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top