-->
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: Stored Procedures MappingException: Unknown entity
PostPosted: Mon Sep 25, 2006 1:48 pm 
Newbie

Joined: Thu Jun 01, 2006 8:51 am
Posts: 6
Hi All,

The configuration is as given below. The problem is that i get a MappingException Unknown entity com.csc.opm.dataaccess.valueobjects.TaskTaskInstanceVO. The problem is my Tomcat Context does not start because of this problem. I am also using Spring Framework with Hibernate.

I feel the exception is saying i am not finding the mapping in hibernate.cfg.xml file.

My Question is when i have specified the Class and the mapping of the member variable and table columns, What more is required? Why should the result of a Stored Procedure map to a Class which is defined in hbm file. I want to use the result only for displaying and not for any manipulation.

I have read through the documentation but i really don't see anything particular that i need to fix this.

Please help fix this problem.

Thanks
Prashanth

Hibernate version: Hibernate 3.2RC4

Mapping documents:
Code:
    <sql-query name="getAllTasks" callable="true">
        <return alias="task" class="com.wirelessmob.dataaccess.valueobjects.TaskTaskInstanceVO">
         <return-property name="taskId" column="TASKID_"/>
         <return-property name="taskName" column="TASKNAME_"/>
         <return-property name="processDefinitionId" column="PROCESSDEFINITION_"/>
         <return-property name="description" column="DESCRIPTION_"/>
         <return-property name="dueDate" column="DUEDATE_"/>
         <return-property name="startStateId" column="STARTSTATE_"/>
         <return-property name="taskNode" column="TASKNODE_"/>
         <return-property name="taskinstanceId" column="ID_ TASKINSTANCEID_"/>
         <return-property name="create" column="CREATE_"/>
         <return-property name="priority" column="PRIORITY_"/>
         <return-property name="isCancelled" column="ISCANCELLED_"/>
         <return-property name="isSuspended" column="ISSUSPENDED_"/>
         <return-property name="isOpen" column="ISOPEN_"/>
         <return-property name="isSignalling" column="ISSIGNALLING_"/>
         <return-property name="isBlocking" column="ISBLOCKING_"/>
         <return-property name="tokenStart" column="TOKENSTART_"/>
         <return-property name="tokenEnd" column="TOKENEND_"/>
         <return-property name="processInstance" column="PROCESSINSTANCE_"/>
         <return-property name="isTerminationImplicit" column="ISTERMINATIONIMPLICIT_"/>
        </return>
        { ? = call FN_JBPM_TASK_TASKINSTANCE(:processDefinitionId) }
    </sql-query>


Full stack trace of any exception that occurs:
Code:
org.hibernate.MappingException: Unknown entity: com.wirelessmob.dataaccess.valueobjects.TaskTaskInstanceVO
        at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:548)
        at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.getSQLLoadable(SQLQueryReturnProcessor.java:312)
        at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processRootReturn(SQLQueryReturnProcessor.java:353)
        at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processReturn(SQLQueryReturnProcessor.java:332)
        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:444)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:351)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:871)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:797)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:908)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:875)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:240)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:132)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:153)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:248)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:337)
        at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
        at com.wirelessmob.webapp.listener.StartupListener.contextInitialized(StartupListener.java:36)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
        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:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)


Name and version of the database you are using:
Oracle 9i

_________________
Thanks a lot

Prash


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 26, 2006 4:47 am 
Newbie

Joined: Thu Jun 01, 2006 8:51 am
Posts: 6
Hi All,

Just amazed by the way Hibernate generates Queries. Hibernate Rocks.

Yippie. I figured it out myself. It feels really good to figure out how to use Hibernate. Everyday is a challenge when using hibernate.

The good thing about Hibernate is is that it has so much documentation but the bad thing is you should have read the whole thing to easily work with Hibernate. Suppose you want to know about Stored Procedures, just reading the Stored Procedures section is not enough. Not complaining, I am thankful atleast this form of documentation is there.

The Solution:
---------------
Use <return-scalar> to define the columns and then use the Transformer. The reason you have to define <return-scalar> is that the column names come back in CAPITAL and hibernate will complain that there is no mapping defined for that column.

Code:
    <sql-query name="getAllTasks" callable="true">
       <return-scalar column="taskId" type="long"/>
       <return-scalar column="taskName" type="string"/>
        { ? = call FN_TEST_TASK_TASKINSTANCE(:processDefinitionId) }
    </sql-query>


Code:
Query query = session.getNamedQuery("getAllTasks");
query.setParameter("processDefinitionId", new Long(processDefinitionId));
query.setResultTransformer(Transformers.aliasToBean(TaskTaskInstanceVO.class));


I wasted almost 8 to 12 hours on this one. I hope this is helpful to some newbie. Thanks a lot for MAX for introducing the ResultTransformer in Query.

I hope i will use Hibernate in the next project, so what i learnt does not go waste.

Rgds
Prashanth


Top
 Profile  
 
 Post subject: Re: Stored Procedures MappingException: Unknown entity
PostPosted: Fri May 20, 2011 10:33 am 
Newbie

Joined: Fri May 20, 2011 10:20 am
Posts: 1
Thanks Prashanth, I really appreciated this post.
I was up to 2 hours looking at this. By your experience I guess you've saved me at least 6 more.

I was trying to use the "return alias" tag and getting the unknown entity error.
I was using a data transfer object (package.MySummaryDto) to retrieve results from a native query.
It's Friday afternoon and I can't face looking at this any more (hibernate blues...) but I just couldn't get it to work using the alias.

Anyway, thanks again. I can now go home for a weekend!


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.