Hibernate version: 3.0.5 (with spring 1.2.4)
Mapping documents: AndroMDA generated
applicationContext.xml:
Code:
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="dataSource"/></property>
<property name="mappingResources">
<list>
<value>hu/freesoft/om/toad/NyelvSzoveg.hbm.xml</value>
<value>hu/freesoft/om/toad/funkcioJog/Menupont.hbm.xml</value>
....
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.query_cache_factory">org.hibernate.cache.StandardQueryCacheFactory</prop>
</props>
</property>
</bean>
Code between sessionFactory.openSession() and session.close(): AndroMDA generated
Full stack trace of any exception that occurs:Code:
org.hibernate.MappingException: Unknown entity: hu.freesoft.om.toad.NyelvSzoveg
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:46)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:314)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1303)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at hu.freesoft.service.toad.lov.menupontLOV.MenupontLOVProviderDaoImpl.listLOV(MenupontLOVProviderDaoImpl.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Name and version of the database you are using: Oracle 10g
The generated SQL (show_sql=true): none
If I try to use DetachedCriteria then I get
MappingException: Unknown entity, but if I use createQuery instead createCriteria, then it works with the same classes and query. If I try to create a simple criteria on the 'unknown' class (NyelvSzoveg.class) then it works too.
The code of the criteria:
Code:
org.hibernate.Criteria criteria = super.getSession(false).createCriteria(hu.freesoft.om.toad.funkcioJog.Menupont.class, "mp");
DetachedCriteria dc = DetachedCriteria.forClass(hu.freesoft.om.toad.NyelvSzoveg.class, "nysz");
dc.setProjection(Property.forName("nysz.nevObj.id"));
dc.add(Restrictions.ilike("nysz.megnevezes", szuro.getMegnevezes()));
criteria.add(Subqueries.propertyIn("mp.id", dc));
The code of the query:
Code:
query = super.getSession(false).createQuery(
"from hu.freesoft.om.toad.funkcioJog.Menupont mp" +
" where mp.id in (" +
"select nysz.nevObj.id " +
"from hu.freesoft.om.toad.NyelvSzoveg nysz " +
"where nysz.megnevezes like '%blahblah%')");
What I really want to do is the next detachedcriteria, but it's not working too:
Code:
org.hibernate.Criteria criteria = super.getSession(false).createCriteria(hu.freesoft.om.toad.funkcioJog.Menupont.class, "mp");
DetachedCriteria dc = DetachedCriteria.forClass(hu.freesoft.om.toad.NyelvSzoveg.class, "nysz");
dc.setProjection(Property.forName("nysz.nevObj.id"));
dc.add(Restrictions.ilike("nysz.megnevezes", "%blahblah%"));
dc.add(Restrictions.eqProperty("nysz.nevObj.id", "mp.kir3Objektum.id"));
criteria.add(Subqueries.exists(dc));