Issues
- CLONE - One-to-Many relationship not working with custom LoaderHHH-11599
- generate schema update script does not respect default schema and default catalog when querying foreign key contraintsHHH-5918Resolved issue: HHH-5918Former user
- Hibernate increases version on readHHH-5867Resolved issue: HHH-5867Strong Liu
- Used unsaved-value="any" for <composite-id>, Getting exception Object references an unsaved transient instance - save the transient instance before flushing, even though record exist in the DBHHH-5170Resolved issue: HHH-5170
- @TableGenerator throws Unsupported exception - error performing isolated workHHH-5019Resolved issue: HHH-5019
- executeUpdate (Query object) on entity that have joined-subclass, perform an immediate commit (updates commits before calling transaction.commit() )HHH-4746Resolved issue: HHH-4746
- ClassCastException with parameter as CASE resultsHHH-4700Resolved issue: HHH-4700Steve Ebersole
- PersistentMap.readFrom does not read records which have NULL in the elementHHH-4515Resolved issue: HHH-4515
- Constraing Violation while using MapHHH-4505Resolved issue: HHH-4505
- improving the performance of the object loading in hibernateHHH-4086Resolved issue: HHH-4086
- One-to-one: property-ref: foreign key: composite-idHHH-4014Resolved issue: HHH-4014
- Add setReadOnly(true) method to the Criteria interfaceHHH-3578Resolved issue: HHH-3578Former user
- The attribute property-ref is supported for the element key-many-to-one, but is not defined in the dtd.HHH-3535Resolved issue: HHH-3535
- Custom Oracle Batcher to allow batch updates for versioned dataHHH-3360Resolved issue: HHH-3360Steve Ebersole
- One-to-Many relationship not working with custom LoaderHHH-3273Resolved issue: HHH-3273
- JndiBoundTreeCacheProviderHHH-3142Resolved issue: HHH-3142
- order by with sub-selectHHH-3118Resolved issue: HHH-3118Christian Beikov
- Incorrect SQL with not-equal operator '<>' on entities with composite keyHHH-3022Resolved issue: HHH-3022
- Bug in dirty checking of Entities with char[]HHH-3009Resolved issue: HHH-3009Former user
- Would like HQL support in criteria.OrderHHH-2987Resolved issue: HHH-2987
- Native SQLQuey combined with addEntity forces to retrieve all columnsHHH-2974Resolved issue: HHH-2974
- missing column name due to IndexNode.resolve calling queryableCollection.getIndexColumnNames()HHH-2964Resolved issue: HHH-2964
- Incomplete/non-informative javadocs for events systemHHH-2958Resolved issue: HHH-2958Diego Plentz
- HIbernate reflection optimization with javassist MUCH slower than in previous versions with cglibHHH-2867Resolved issue: HHH-2867
- org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of natural Key componentHHH-2843Resolved issue: HHH-2843
- java.lang.NullPointerException regression between 3.2.2 and 3.2.3HHH-2834Resolved issue: HHH-2834
- insert-select query fails with NPE when select includes joinHHH-2833Resolved issue: HHH-2833Steve Ebersole
- getting erroneous behavior when specifying alias without column in WHEREHHH-2832Resolved issue: HHH-2832
- DefaultFlushEntityEventListener.checkNaturalId() causes extra SELECTs on read-only entitiesHHH-2816Resolved issue: HHH-2816Chris Bredesen
- DELETE hql statement generating bad SQL on postgres 8.2HHH-2812Resolved issue: HHH-2812Diego Plentz
- dialect changes: limit stringHHH-2809Resolved issue: HHH-2809Strong Liu
- nonthreadsafe exception in a case where I have only the main threadHHH-2765Resolved issue: HHH-2765
- MappedSuperclass + M:N relation + PostUpdateListener = AssertionFailure: collection [xyz] was not processed by flush()HHH-2751Resolved issue: HHH-2751Diego Plentz
- Oracle9i dialect do not support SequenceStyleGeneratorHHH-2750Resolved issue: HHH-2750
- 'illegal attempt to dereference collection' when referencing a single-valued association in an implicit joinHHH-2739Resolved issue: HHH-2739Steve Ebersole
- Inserts get done even when flushmode == manual and they are not necessaryHHH-2729Resolved issue: HHH-2729
- Informix dialect generates incorrect ALTER TABLE statementHHH-2709Resolved issue: HHH-2709Chris Bredesen
- Workaround for bug in PostgreSQL JDBC driverHHH-2699Resolved issue: HHH-2699Diego Plentz
- Cascade delete and ternary association after upgradeHHH-2690Resolved issue: HHH-2690
- Include a primary key in the sequence table used by id.enhanced.TableGeneratorHHH-2686Resolved issue: HHH-2686Steve Ebersole
- 'illegal attempt to dereference collection' when using auto-joinHHH-2667Resolved issue: HHH-2667
- SQLServer2005Dialect (ROW_NUMBER for Paging)HHH-2655Resolved issue: HHH-2655Strong Liu
- Synchronization bottleneck in EntityModeToTuplizerMappingHHH-2645Resolved issue: HHH-2645Former user
- Illegal JNDI lookup of java:comp/websphere/ExtendedJTATransaction in beforeCompletion method in WebSphere 6.1.0.5HHH-2632Resolved issue: HHH-2632
- Generated properties leak prepared statements in Hibernate 3.2.3 and higher.HHH-2627Resolved issue: HHH-2627Former user
- Bug in handling null references to Components / Embeddables when using session / entityManager.merge()HHH-2626Resolved issue: HHH-2626Former user
- Attribute override ignored when used with InheritenceHHH-2619
- Blob Length Set to 255 By Default With Derby DBHHH-2614Resolved issue: HHH-2614Strong Liu
- Invalid SQL generation for dynamic filterHHH-2610Resolved issue: HHH-2610
- Missing documentation in section 5.1.10HHH-2601Resolved issue: HHH-2601Steve Ebersole
50 of 86
CLONE - One-to-Many relationship not working with custom Loader
Created March 28, 2017 at 12:48 PM
Updated March 28, 2017 at 12:49 PM
Activity
Show:
Blazej AdamczykMarch 28, 2017 at 12:49 PM
The issue is still present in Hibernate 5.0.11.Final. The collection is not initialized correctly in NamedQueryCollectionInitializer. It calls only the list() and does nothing with it.
Within the context of a One-to-Many relationship, NamedQueryCollectionInitializer .initialize() never actually populates the PersistantBag on the parent after it calls query.setCollectionKey( key ).setFlushMode( FlushMode.MANUAL ).list() to retrieve the children.
This is documented in the forums here: http://forums.hibernate.org/viewtopic.php?t=986428
Additionally, the poster has a fix posted which may solve the problem, or at least lay out the groundwork for a solution. Here is the proposed implementation of NamedQueryCollectionInitializer.initialize():
public void initialize(Serializable key, SessionImplementor session)
throws HibernateException {
if (log.isDebugEnabled()) {
log.debug("initializing collection: " + persister.getRole()
+ " using named query: " + queryName);
}
// TODO: is there a more elegant way than downcasting?
AbstractQueryImpl query = (AbstractQueryImpl) session
.getNamedSQLQuery(queryName);
if (query.getNamedParameters().length > 0) {
query.setParameter(query.getNamedParameters()[0], key, persister
.getKeyType());
} else {
query.setParameter(0, key, persister.getKeyType());
}
List list = query.setCollectionKey(key).setFlushMode(FlushMode.MANUAL)
.list();
// Uh, how 'bout we save the collection for later retrieval?
CollectionKey collectionKey = new CollectionKey(persister, key, session
.getEntityMode());
for (Object object : session.getPersistenceContext()
.getCollectionsByKey().keySet()) {
if (collectionKey.equals(object)) {
PersistentCollection persistentCollection = session
.getPersistenceContext().getCollection(collectionKey);
Serializable[] serializables = new Serializable[list.size()];
for (int i = 0; i < list.size(); i++) {
serializables[i] = persister.getElementType().disassemble(
list.get, session,
persistentCollection.getOwner());
}
persistentCollection.initializeFromCache(persister,
serializables, persistentCollection.getOwner());
persistentCollection.setSnapshot(key, persistentCollection
.getRole(), serializables);
persistentCollection.afterInitialize();
session.getPersistenceContext().getCollectionEntry(
persistentCollection).postInitialize(
persistentCollection);
}
}
}