[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3108?page=c...
]
Marcin Mościcki commented on HHH-3108:
--------------------------------------
Ok,
the problem with issue 2) (empty collection) was caused by missing 'column'
attribute for <key> element inside the <set>.
This is, however, how it was presented in the hibernate docs...
Issue 1) remains - I'll have a deeper look at it later.
<load-collection role="entity_name.property">
doesn't work
----------------------------------------------------------
Key: HHH-3108
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3108
Project: Hibernate3
Issue Type: Bug
Components: metamodel
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6, Oracle 9 (insignificant)
Reporter: Marcin Mościcki
Priority: Minor
Attachments: hibernatebug.zip
I use an <sql-query> for a <loader> in a collection owned by a named entity.
The role attribute is set to "<entity-name>.<property-name>" -
exactly the key under witch the collection's meta data is registered in
SessionFactoryImpl.collectionPersisters map - but when the query is being added,
SessionFactoryImpl looks for it under the key
"<package>.<entity-name>.<property-name>" in this map, and
doesn't find it.
When entity-name attribute is removed from the entity mapping and unqualified class name
is used to refer to it instead, everything works fine.
The easiest, and probably most uniform solution would be to introduce a second attribute
"entity-role" to the load-collection element.
The following exception results from mapping:
<hibernate-mapping package="hibernatedemo.model">
....
<class table="persons_test" entity-name="person"
name="Person">
....
<set name="personMap" inverse="true">
<key/>
<one-to-many entity-name="person_map"/>
<loader query-ref="fetch_person_map_by_person"/>
</set>
</class>
<sql-query name="fetch_person_map_by_person">
<load-collection alias="map" role="person.personMap" />
select {map.*} from persons_map_test map where map.person_id=:id
</sql-query>
org.hibernate.MappingException: Unknown collection role:
hibernatedemo.model.person.personMap
at
org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:558)
at
org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.addCollection(SQLQueryReturnProcessor.java:370)
at
org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processCollectionReturn(SQLQueryReturnProcessor.java:405)
at
org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processReturn(SQLQueryReturnProcessor.java:335)
at
org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.process(SQLQueryReturnProcessor.java:148)
at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:64)
at
org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:43)
at
org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:114)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:446)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:352)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at hibernatedemo.Test.getHibernateSession(Test.java:44)
at hibernatedemo.Test.main(Test.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira