Entity with composite-id and serial foreign-key one-to-many set mapping can't be saved under 3.3.x and under 3.2.x can be saved but can't fetch set to father object

Description

Mapping:
<class name="ExtraInfo" table="extrainfo">
<composite-id class="ExtraInfoId" name="key">
<key-property column="sn" length="20" name="cid" type="string"/>
<key-property column="composite" length="2" name="composite" type="string"/>
<key-property column="fileName" length="300" name="fileName" type="string"/>
</composite-id>
<property name="id" generated="insert" insert="false" type="java.lang.Integer" unique="true" update="false">
<column name="id" not-null="true"/>
</property>
...
<setinverse="true" name="scanDatas">
<key property-ref="id">
<column name="id"/>
</key>
<one-to-many class="ScanData"/>
</set>
</class>
<class name="ScanData" table="scandata">
<composite-id class="net.vuniverse.app.biochemanalysis.db.model.ScanDataId" name="key">
<key-property column="id" name="id" type="java.lang.Integer"/>
<key-property column="idx" name="idx" type="java.lang.Integer"/>
</composite-id>
<many-to-one fetch="join" insert="false" name="extraInfo" property-ref="id" update="false">
<column name="id"/>
</many-to-one>
<property name="data" type="java.lang.Float">
<column name="data" precision="8" scale="8"/>
</property>
</class>
Code:
ExtraInfoId eid = new ExtraInfoId("a", "1", "aa.txt");
ExtraInfo extra = new ExtraInfo(eid);
session.save(extra);
session.flush();
int id = extra.getId();
for (int i = 0; i < 3; i++) {
ScanData sd = new ScanData(new ScanDataId(id, 1));
sd.setData(0.5f * (i + 1));
session.save(sd);
}
session.flush();
extra = session.createQuery("from ExtraInfo a left join fetch a.scandatas b where a.id='" + id + "'").list().get(0);
Set<ScanData> scandatas = extra.getScanDatas();
for (ScanData sd : scandatas) {
System.out.println(sd.getData());
}

under all version, mapping can be varified correctly.
under version 3.2.5, new ExtraInfo can be saved. but the query with "left join fetch" can't return a Extra with set full of ScanData. the size of scandatas is 0.

under version 3.3.x, new ExtraInfo can't be saved. and the following exception is thrown:

java.lang.ClassCastException: java.lang.Integer
at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:400)
at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:307)
at org.hibernate.engine.Collections.processReachableCollection(Collections.java:199)
at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:60)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:124)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:84)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:78)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:161)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:49)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
.........

Environment

jdk1.6.0_13
windows 2003 server
hibernate 3.2.5, 3.3.1, 3.3.2
database: postgreSQL8.4

Activity

Show:
Yi, Han
October 16, 2009, 3:24 PM

I've known why under 3.2.5 the set is empty. it's because of the query under the same session context got the same ExtraInfo which had existed and without a not-empty set.
but in the other session, just query on the same condition, the new exception was thrown:

org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of net.vuniverse.db.ExtrainfoId.sn
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:64)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:70)
at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:86)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:353)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:184)
at org.hibernate.engine.EntityKey.generateHashCode(EntityKey.java:104)
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:48)
at org.hibernate.engine.StatefulPersistenceContext.getCollectionOwner(StatefulPersistenceContext.java:678)
at org.hibernate.engine.loading.CollectionLoadContext.getLoadingCollection(CollectionLoadContext.java:107)
at org.hibernate.loader.Loader.readCollectionElement(Loader.java:1003)
at org.hibernate.loader.Loader.readCollectionElements(Loader.java:646)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:591)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
......

Brett Meyer
April 7, 2014, 5:41 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Brett Meyer
July 8, 2014, 3:12 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Rejected

Assignee

Unassigned

Reporter

Yi, Han

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major