HibernateException "Unable to resolve owner of loading collection ..." in EAP 6
Issue
- An entity class uses an
@Embeddablekey class which consists of one or moreStringproperties - An instance of the key class instantiated using a
Stringwith one or more trailing spaces is used to load an entity from a Sybase database
DepartmentKey key = new DepartmentPK("engineering ");
Department dep = entityManager.find(Department.class, key);
- When navigating a
*toManyassociation from the returned entity, the following exception may be raised:
org.hibernate.HibernateException: Unable to resolve owner of loading collection [[org.test.Department.employees#component[name]{name=engineering}]] for second level caching
at org.hibernate.engine.loading.internal.CollectionLoadContext.addCollectionToCache(CollectionLoadContext.java:321)
at org.hibernate.engine.loading.internal.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:262)
at org.hibernate.engine.loading.internal.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:233)
at org.hibernate.engine.loading.internal.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:209)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:1150)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1119)
at org.hibernate.loader.Loader.processResultSet(Loader.java:964)
at org.hibernate.loader.Loader.doQuery(Loader.java:911)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:312)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2238)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:65)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:674)
at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:85)
at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1855)
at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:549)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:234)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:545)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:124)
at org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:180)
- In cases where both the primary key object and foreign key object have been loaded into the level 2 cache in a different persistence context (session or entity manager) prior to the above operations, the association navigation may simply return an empty result set (without raising an exception) - a result which is still unexpected if there are foreign key rows in the database that match the persisted primary key
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6
- Hibernate 4
- Sybase
- Microsoft SQL Server
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
