-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: MappingException if DetachedCriteria is used
PostPosted: Thu Nov 03, 2005 11:44 am 
Newbie

Joined: Thu Nov 03, 2005 11:21 am
Posts: 2
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));


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 10:50 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:54 am
Posts: 28
I have exactly the same problem with Hibernate v3.1.3 and Spring v1.2.7. Is there a solution to this issue ?

Regards, Stefan Lecho.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2008 4:57 am 
Newbie

Joined: Mon Jul 21, 2008 5:12 am
Posts: 13
Are any solutions on this issue exist?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.