Issues
- JoinColumn on non key field fails to populate collectionHHH-6204Resolved issue: HHH-6204Steve Ebersole
- HqlLexer can cause ClassNotFound in OSGi environmentHHH-6165Resolved issue: HHH-6165
- HSQLDialect support for ROWNUMHHH-6012Resolved issue: HHH-6012
- Methos generate in org.hibernate.id.enhanced.OptimizerFactory$PooledLoOptimizer classs is not synchronizedHHH-5872Resolved issue: HHH-5872
- Hibernate increases version on readHHH-5867Resolved issue: HHH-5867Strong Liu
- Hibernate 3.5.4 doesn't build with OpenJDK 6b18-1.8.2 or greaterHHH-5789Resolved issue: HHH-5789Strong Liu
- Hibernate complains about an unknown mappedBy property when mapping a bidirectional OneToOne relation with a derived identifierHHH-5695Resolved issue: HHH-5695Brett Meyer
- Using compound primary key throws SQLExceptionHHH-5675Resolved issue: HHH-5675
- FilterOverrides AnnotationHHH-5674Resolved issue: HHH-5674
- JPA 2 orphanRemoval on OneToOne relation does not work properlyHHH-5559Resolved issue: HHH-5559Emmanuel Bernard
- DbTimestamp uses local time for @Version field on Oracle 11gHHH-5553Resolved issue: HHH-5553
- Hibernate fails with two kinds of exceptions on a compsite-key join table that references two composite keys (one column shared by both foreign keys)HHH-5488Resolved issue: HHH-5488Former user
- add <developers/> section to pom (else nexus complains on deploy)HHH-5487Resolved issue: HHH-5487Steve Ebersole
- The interface method org.hibernate.id.ResultSetIdentifierConsumer.consumeIdentifier(ResultSet resultSet) should throw SQLExceptionHHH-5486
- Move hiberante dtd files from http://hibernate.sourceforge.net to http://www.hibernate.org/dtdHHH-5485Resolved issue: HHH-5485Hardy Ferentschik
- org.hibernate.type.UUIDCharType incorrectly mapped to char and causes test fail due to the padding spaceHHH-5484Resolved issue: HHH-5484Strong Liu
- Clean up usages of now deprecated ExtendedMappingsHHH-5474Resolved issue: HHH-5474Steve Ebersole
- Default for CHECK_NULLABILITY does not allow merge retriesHHH-5473Resolved issue: HHH-5473Former user
- JdbcSupportLoader throws AbstractMethodError on JDBC < 1.4HHH-5459Resolved issue: HHH-5459
- withClause SQL for many-to-many association uses table alias before it is definedHHH-5455Resolved issue: HHH-5455
- With hibernate.order_inserts=true Hibernate executes SQL inserts in wrong orderHHH-5454Resolved issue: HHH-5454
- Deployment of site.xmlHHH-5439Resolved issue: HHH-5439Steve Ebersole
- Skip deployment of "irrelevant" modulesHHH-5438Resolved issue: HHH-5438Steve Ebersole
- Cannot parse order-by fragment if it contains a registered function without parenthesesHHH-5225Resolved issue: HHH-5225Former user
JoinColumn on non key field fails to populate collection
Details
Assignee
Steve EbersoleSteve EbersoleReporter
Christopher SamsChristopher Sams(Deactivated)Time tracking
6.12h loggedComponents
Fix versions
Priority
Major
Details
Details
Assignee
Reporter
Time tracking
Components
Fix versions
Priority
Activity
Brett MeyerMarch 7, 2014 at 10:08 PM
Bulk closing tickets resolved in released versions
Strong LiuJuly 25, 2012 at 3:41 AM
you commited this to the master branch, which i think it should be ported to 4.1 branch as well
Strong LiuJuly 23, 2012 at 6:12 PM
org.hibernate.type.CollectionType#getKeyOfOwner returns entity instance as collection key instead of composite pk instance, which is expected
Strong LiuJuly 23, 2012 at 6:09 PM
I have some analysis on this issue:
when initialising an EntityKey (with this constructor public EntityKey(Serializable id, EntityPersister persister, EntityMode entityMode)), somehow, the serializable id instance is actually the Entity (with embedded id) instance itself, and identifierType get by `this.identifierType = persister.getIdentifierType();` is correct – the embedded id type.
the method org.hibernate.engine.EntityKey#generateHashCode is called during initialising time, and it then calls `identifierType.getHashCode( identifier, entityMode, factory )`
since identifierType is actually ComponentType, so, in the method getHashCode, this class will using getters to get each filed values from identifier, then there is a type mismatch happens, the identifier type here is supposed to be the embedded pk instance, which it is actually the entity class instance.
so, the https://gist.github.com/3164408 exception throws
Steve EbersoleJuly 23, 2012 at 6:05 PMEdited
[10:47] <sebersole> have you looked at it at all?
[10:47] <stliu> sebersole: yes, i looked it in the last weekend
[10:48] <stliu> org.hibernate.engine.EntityKey#EntityKey
[10:49] <sebersole> what about entitykey?
[10:49] <stliu> in this constructor, "this.identifierType = persister.getIdentifierType();" has correct identifierType (the composite pk type)
[10:49] <stliu> "this.identifier = id; ", but is the entity it self, not the instance of composite pk
[10:50] <stliu> so, in the method of org.hibernate.engine.EntityKey#generateHashCode
[10:50] <stliu> identifierType.getHashCode( identifier, entityMode, factory );
[10:50] <sebersole> it is a "non aggregated composite pk"?
[10:50] <stliu> correct
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.