-->
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: one-to-many not mapped when Hiberntae 3.1.2 gets here.
PostPosted: Mon Feb 06, 2006 6:35 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
I have a one-to-many relationship called stateTokenRecords that is mapped as follows:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.perfretail.k2v1.tahiti.statetoken" default-lazy="false" >
    <class name="StateToken" table="state_token_header">
        <id name="uuid" column="UUID" type="com.perfretail.k2v1.uuids.UuidObjectType">
            <generator class="assigned"/>
        </id>
        <property name="chainUuid" column="CHAIN_UUID" type="com.perfretail.k2v1.uuids.ChainUuidType"/>
        <property name="name" column="NAME" type="string" not-null="true"/>
        <property name="status" column="STATUS" type="string" not-null="true"/>
        <property name="updateDate" column="UPDATE_DATE" type="long" not-null="true"/>
        <property name="createDate" column="CREATE_DATE" type="long" not-null="true"/>
        <list name="stateTokenRecords" lazy="true" inverse="true" cascade="all-delete-orphan">
            <key column="TOKEN_UUID"/>
            <index column="INDX"/>
            <one-to-many class="StateTokenRecord"/>
        </list>
    </class>
    <class name="StateTokenRecord" table="state_token_detail">
        <id name="uuid" column="UUID" type="com.perfretail.k2v1.uuids.UuidObjectType" unsaved-value="any">
            <generator class="assigned"/>
        </id>
        <many-to-one name="parent" column="TOKEN_UUID" class="StateToken" not-null="true"/>
        <property name="index" column="INDX" type="int" not-null="true"/>
        <property name="owner" column="OWNER" type="class" not-null="true"/>
        <property name="eventType" column="EVENT_TYPE" type="string" not-null="true"/>
        <property name="eventContextClass" column="EVENT_CONTEXT_CLASS" type="class"/>
        <property name="eventContextId" column="EVENT_CONTEXT_ID" type="string"/>
        <property name="status" column="STATUS" type="string" not-null="true"/>
        <property name="transactionId" column="TXN_UUID" type="string"/>
        <property name="createDate" column="CREATE_DATE" type="long" not-null="true"/>
    </class>
    <class name="BunchIterator" table="bunch_iterator">
        <id name="id" column="UUID" type="com.perfretail.k2v1.uuids.UuidObjectType">
            <generator class="assigned"/>
        </id>
        <property name="index" column="INDX" type="int" not-null="true"/>
    </class>
</hibernate-mapping>



I have a query that references this, as follows:

Code:
               List records=getHibernateTemplate().find("select srec "
                     +"from StateToken tok, tok.stateTokenRecords srec "
                     +"where tok.uuid = ? "
                     +"and srec.owner = ? "
                     +"and srec.eventType = ? "
                     +"and srec.eventContextClass = ? "
                     +"and srec.eventContextId = ? "
                     +"and srec.status = ? ",
                     new Object[]{tokenUuid,owner,eventType,eventContextClass,eventContextId,status});
               if(records.size()>0){
                  // attemptTokenUpdate is true and record was already inserted
                  // found a record already return this instead and DO NOT perform callback operation
                  return records.get(0);


When this executes, I get the following "is not mapped" error:
Code:
2006-02-06 16:28:28,258 INFO [com.perfretail.k2v1.tahiti.EventBus.TEventWorker] - <times is 137>
2006-02-06 16:28:28,289 ERROR [com.perfretail.k2v1.tahiti.EventBus.TEventWorker] - <Hosed event is com.perfretail.k2v1.tahiti.EventBus.TCommandEvent@10aeb17[type=POS_JOURNAL_MDATA_REQUEST,contextInterface=interface com.perfretail.k2v1.envoys.sales.ISalesRollupEnvoy,contextId=UUID_Bubbas Butts and Brews,stateToken=com.perfretail.k2v1.tahiti.statetoken.StateToken@2d14a]>
org.springframework.orm.hibernate3.HibernateQueryException: tok.stateTokenRecords is not mapped. [select srec from com.perfretail.k2v1.tahiti.statetoken.StateToken tok, tok.stateTokenRecords srec where tok.uuid = ? and srec.owner = ? and srec.eventType = ? and srec.eventContextClass = ? and srec.eventContextId = ? and srec.status = ? ]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: tok.stateTokenRecords is not mapped. [select srec from com.perfretail.k2v1.tahiti.statetoken.StateToken tok, tok.stateTokenRecords srec where tok.uuid = ? and srec.owner = ? and srec.eventType = ? and srec.eventContextClass = ? and srec.eventContextId = ? and srec.status = ? ]
org.hibernate.hql.ast.QuerySyntaxException: tok.stateTokenRecords is not mapped. [select srec from com.perfretail.k2v1.tahiti.statetoken.StateToken tok, tok.stateTokenRecords srec where tok.uuid = ? and srec.owner = ? and srec.eventType = ? and srec.eventContextClass = ? and srec.eventContextId = ? and srec.status = ? ]
   at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:157)
   at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:86)
   at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
   at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:263)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3049)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
   at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
   at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
   at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
   at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:819)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
   at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:817)
   at com.perfretail.k2v1.tahiti.statetoken.StateTokenDao$2.doInHibernate(StateTokenDao.java:84)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:333)
   at com.perfretail.k2v1.tahiti.statetoken.StateTokenDao.addStateTokenRecord(StateTokenDao.java:74)
   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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
   at $Proxy1.addStateTokenRecord(Unknown Source)
   at com.perfretail.k2v1.tahiti.statetoken.StateTokenService.updateToken(StateTokenService.java:49)
   at com.perfretail.k2v1.tahiti.DirectorComponent.fireResultEvent(DirectorComponent.java:208)
   at com.perfretail.k2v1.tahiti.DirectorComponent.fireResultEvent(DirectorComponent.java:229)
   at com.perfretail.k2v1.processors.POSJournal.POSMetaDataGenerator.calculateXactionGapRecords(POSMetaDataGenerator.java:157)
   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 com.perfretail.k2v1.tahiti.DirectorComponent.invokeEventMethod(DirectorComponent.java:284)
   at com.perfretail.k2v1.tahiti.DirectorComponent.onEvent(DirectorComponent.java:188)
   at com.perfretail.k2v1.tahiti.EventBus.TEventWorker.run(TEventWorker.java:42)
   at java.lang.Thread.run(Thread.java:595)
   at com.perfretail.k2v1.tahiti.EventBus.TEventQueueTrivial.addEvent(TEventQueueTrivial.java:74)
   at com.perfretail.k2v1.tahiti.Director.handleAbstractEvent(Director.java:243)
   at com.perfretail.k2v1.tahiti.Director.handleCommandEvent(Director.java:234)
   at com.perfretail.k2v1.tahiti.statetoken.StateTokenService.onInitPhase1Done(StateTokenService.java:150)
   at com.perfretail.k2v1.tahiti.DirectorComponent.onEvent(DirectorComponent.java:180)
   at com.perfretail.k2v1.tahiti.EventBus.TEventWorker.run(TEventWorker.java:42)
   at java.lang.Thread.run(Thread.java:595)
   at com.perfretail.k2v1.tahiti.EventBus.TEventQueueTrivial.addEvent(TEventQueueTrivial.java:74)
   at com.perfretail.k2v1.tahiti.Director.handleAbstractEvent(Director.java:243)
   at com.perfretail.k2v1.tahiti.Director.handleEvent(Director.java:228)
   at com.perfretail.k2v1.tahiti.Director.onApplicationEvent(Director.java:390)
   at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:45)
   at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:225)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:323)
   at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
   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 org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104)
   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.deployDirectory(HostConfig.java:894)
   at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:857)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
   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:683)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
   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:271)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Caused by:  tok.stateTokenRecords is not mapped.


AFAIK this was fine under Spring 1.1.5 and Hibernate 2.x, but is causing problems now. Can anyone lend assistance? Thanks.

_________________
--Pierce Krouse


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 8:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Try change
Code:
+"from StateToken tok, tok.stateTokenRecords srec "

to
Code:
+"from StateToken tok left join tok.stateTokenRecords srec "
.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 9:14 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 2:54 pm
Posts: 33
Location: Austin, TX
That did it David, thanks!

At first I was puzzled about why it's necessary to join a collection like that, but it kinda makes sense when I think about it.

_________________
--Pierce Krouse


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.