[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6204) JoinColumn on non key field fails to populate collection
Chris Sams (JIRA)
noreply at atlassian.com
Fri May 6 13:01:59 EDT 2011
JoinColumn on non key field fails to populate collection
--------------------------------------------------------
Key: HHH-6204
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6204
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.Alpha3, 3.6.4, 4.0.0.Alpha2, 3.6.3, 4.0.0.Alpha1, 3.6.2, 3.6.1, 3.6.0, 3.6.0.CR2, 3.6.0.CR1, 3.6.0.Beta4, 3.6.0.Beta3, 3.6.0.Beta2, 3.6.0.Beta1, 3.3.2
Environment: EAP 5 (hibernate 3.3.2), hibernate 3.6.x, 4.0.x , probably eap4 as well
Reporter: Chris Sams
Attachments: CompositeKeyExample.zip
To duplicate the issue, create three tables in a database with no declared primary or foreign keys. Map entities to two of the tables. One of these entities has a primitive @Id; the other has an @EmbeddedId. Both entities contain an additional field used to join with the third table and populate a collection.
This works with the entity that has a primitive @Id but for the entity with @EmbeddedId, trying to do anything with the collection after calling the getter results in:
javax.ejb.EJBException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of jboss.example.DoesNotWorkPk.id1
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
....
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of jboss.example.DoesNotWorkPk.id1
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:58)
....
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field jboss.example.DoesNotWorkPk.id1 to jboss.example.DoesNotWork
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
I've attached a sample project. The relevant files are Works.java, DoesNotWork.java, and DoesNotWorkPk.java
There's also data.sql along with the java files to populate a mysql db, but I think any DB will do.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list