-->
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.  [ 4 posts ] 
Author Message
 Post subject: Error on session.find
PostPosted: Tue Dec 16, 2003 11:32 am 
Newbie

Joined: Fri Dec 12, 2003 7:38 am
Posts: 5
Hi, I am new in hybernate.

I use hiberbate 2.0 with Jboss 3.2.1

When I run the following querry:



Code:
         List lst =
            session.find(
               "from TrainRame as trainRame "
                  + " where trainRame.comp_id.train.trajet.circulation= ? "
                  + " and trainRame.comp_id.train.trajet.circulation.startDate >= ? "
                  + " and trainRame.comp_id.train.trajet.circulation.startDate <= ?",
               new Object[] { new Integer(pNumCirculation),
                           new Timestamp(date.getTime()),
                           new Timestamp(date.getTime())},
               new Type[] { Hibernate.INTEGER,
                         Hibernate.TIMESTAMP,
                         Hibernate.TIMESTAMP });






I have this error:

Code:
16:15:23,421 ERROR [STDERR] net.sf.hibernate.QueryException: dereferenced: trainram0_.comp_id.train.trajet.circulation.startDate [from com.thalys.localys.model.TrainRame as trainRame  where trainRame.comp_id.train.trajet.circulation= ?  and trainRame.comp_id.train.trajet.circulation.startDate >= ?  and trainRame.comp_id.train.trajet.circulation.startDate <= ?]
   at net.sf.hibernate.hql.PathExpressionParser.token(PathExpressionParser.java:199)
   at net.sf.hibernate.hql.WhereParser.doPathExpression(WhereParser.java:364)
   at net.sf.hibernate.hql.WhereParser.doToken(WhereParser.java:393)
   at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:279)
   at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
   at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:120)
   at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
   at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:146)
   at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:133)
   at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:352)
   at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:330)
   at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1368)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1332)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1322)
   at com.thalys.localys.messaging.processing.helper.TrainManager.isTrainDoublons(TrainManager.java:135)
   at com.thalys.localys.messaging.processing.helper.TrainManager.start(TrainManager.java:60)
   at com.thalys.localys.messaging.processing.StartCirculation.process(StartCirculation.java:42)
   at com.thalys.localys.messaging.processing.messageprocessor.MessageProcessorBean.processMessage(MessageProcessorBean.java:44)
   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 org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
   at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
   at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
   at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
   at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
   at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
   at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
   at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
   at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
   at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
   at org.jboss.ejb.Container.invoke(Container.java:700)
   at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:375)
   at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:83)
   at $Proxy36.processMessage(Unknown Source)
   at com.thalys.localys.messaging.receiving.MessageReceiverBean.onMessage(MessageReceiverBean.java:60)
   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 org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:460)
   at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
   at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
   at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:144)
   at org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT.invoke(MessageDrivenTxInterceptorBMT.java:32)
   at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:62)
   at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:90)
   at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
   at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
   at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:374)
   at org.jboss.ejb.Container.invoke(Container.java:700)
   at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:824)
   at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1114)
   at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
   at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:633)
   at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:433)
   at org.jboss.mq.SpySession.run(SpySession.java:298)
   at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
   at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:727)
   at java.lang.Thread.run(Thread.java:534)


Do you have an idea of the problem?

Thanks in advance.


Top
 Profile  
 
 Post subject: Correction
PostPosted: Tue Dec 16, 2003 11:46 am 
Newbie

Joined: Fri Dec 12, 2003 7:38 am
Posts: 5
The querry is :

Code:
         List lst =
            session.find(
               "from TrainRame as trainRame "
                  + " where trainRame.comp_id.train.trajet.circulation= ? "
                  + " and trainRame.comp_id.train.trajet.circulation.startDate >= ? "
                  + " and trainRame.comp_id.train.trajet.circulation.stopDate <= ?",
               new Object[] { new Integer(pNumCirculation),
                           new Timestamp(date.getTime()),
                           new Timestamp(date.getTime())},
               new Type[] { Hibernate.INTEGER,
                         Hibernate.TIMESTAMP,
                         Hibernate.TIMESTAMP });



Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 9:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
mapping file??


Top
 Profile  
 
 Post subject: mapping file
PostPosted: Wed Dec 17, 2003 9:39 am 
Newbie

Joined: Fri Dec 12, 2003 7:38 am
Posts: 5
All my mappings files where generated with middleGen. Here is the mapping file for TrainRame


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

    http://boss.bekk.no/boss/middlegen/
    http://hibernate.sourceforge.net/
-->

<class
    name="com.thalys.localys.model.TrainRame"
    table="TRAIN_RAME"
>

    <composite-id name="comp_id" class="com.thalys.localys.model.TrainRamePK">
        <!-- bi-directional many-to-one association to Rame -->
        <key-many-to-one
           name="rame"
           class="com.thalys.localys.model.Rame"
       >
           <column name="NUM_RAME" />
       </key-many-to-one>
        <!-- bi-directional many-to-one association to Train -->
        <key-many-to-one
           name="train"
           class="com.thalys.localys.model.Train"
       >
           <column name="CPT_TRAIN" />
       </key-many-to-one>
    </composite-id>   

    <property
        name="menant"
        type="int"
        column="MENANT"
        length="1"
    />
    <property
        name="orientation"
        type="java.lang.String"
        column="ORIENTATION"
        length="10"
    />
    <property
        name="inversion"
        type="boolean"
        column="INVERSION"
        length="1"
    />
    <property
        name="userAckInversion"
        type="boolean"
        column="USER_ACK_INVERSION"
        length="1"
    />
    <property
        name="distante"
        type="java.lang.String"
        column="DISTANTE"
        length="40"
    />

    <!-- associations -->

</class>
</hibernate-mapping>


The mapping for Train:



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

    http://boss.bekk.no/boss/middlegen/
    http://hibernate.sourceforge.net/
-->

<class
    name="com.thalys.localys.model.Train"
    table="TRAIN"
>

    <id
        name="cptTrain"
        type="int"
        column="CPT_TRAIN"
    >
        <generator class="sequence">
            <param name="sequence">sequence_cpt_train</param>
        </generator>
    </id>

    <property
        name="startDate"
        type="java.sql.Timestamp"
        column="START_DATE"
        not-null="true"
        length="7"
    />
    <property
        name="stopDate"
        type="java.sql.Timestamp"
        column="STOP_DATE"
        length="7"
    />
    <property
        name="wrongMission"
        type="boolean"
        column="WRONG_MISSION"
        not-null="true"
        length="1"
    />
    <property
        name="userAckWrongMission"
        type="boolean"
        column="USER_ACK_WRONG_MISSION"
        length="1"
    />

    <!-- associations -->
    <!-- bi-directional many-to-one association to Trajet -->
    <many-to-one
        name="trajet"
        class="com.thalys.localys.model.Trajet"
        not-null="true"
    >
        <column name="CPT_TRAJET" />
    </many-to-one>
    <!-- bi-directional one-to-many association to Variation -->
    <set
        name="variations"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="CPT_TRAIN" />
        </key>
        <one-to-many
            class="com.thalys.localys.model.Variation"
        />
    </set>
    <!-- bi-directional one-to-many association to Status -->
    <set
        name="status"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="CPT_TRAIN" />
        </key>
        <one-to-many
            class="com.thalys.localys.model.Status"
        />
    </set>
    <!-- bi-directional one-to-many association to Devoiement -->
    <set
        name="devoiements"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="CPT_TRAIN" />
        </key>
        <one-to-many
            class="com.thalys.localys.model.Devoiement"
        />
    </set>
    <!-- bi-directional one-to-many association to TrainRame -->
    <set
        name="trainRames"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="CPT_TRAIN" />
        </key>
        <one-to-many
            class="com.thalys.localys.model.TrainRame"
        />
    </set>

</class>
</hibernate-mapping>


and finally the mapping for Trajet:

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

    http://boss.bekk.no/boss/middlegen/
    http://hibernate.sourceforge.net/
-->

<class
    name="com.thalys.localys.model.Trajet"
    table="TRAJET"
>

    <id
        name="cptTrajet"
        type="int"
        column="CPT_TRAJET"
    >
        <generator class="sequence">
            <param name="sequence">sequence_cpt_trajet</param>
        </generator>
    </id>

    <property
        name="circulation"
        type="int"
        column="CIRCULATION"
        not-null="true"
        length="5"
    >
        <meta attribute="use-in-tostring">true</meta>
    </property>
    <property
        name="startDate"
        type="java.sql.Timestamp"
        column="START_DATE"
        not-null="true"
        length="7"
    >
        <meta attribute="use-in-tostring">true</meta>
    </property>
    <property
        name="stopDate"
        type="java.sql.Timestamp"
        column="STOP_DATE"
        not-null="true"
        length="7"
    >
        <meta attribute="use-in-tostring">true</meta>
    </property>

    <!-- associations -->
    <!-- bi-directional many-to-one association to AxeRelation -->
    <many-to-one
        name="axeRelation"
        class="com.thalys.localys.model.AxeRelation"
        not-null="true"
    >
        <column name="CPT_AXE" />
    </many-to-one>
    <!-- bi-directional one-to-many association to Horaire -->
    <set
        name="horaires"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="CPT_TRAJET" />
        </key>
        <one-to-many
            class="com.thalys.localys.model.Horaire"
        />
    </set>
    <!-- bi-directional one-to-many association to Mission -->
    <set
        name="missionsByCptTrajet1"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="CPT_TRAJET1" />
        </key>
        <one-to-many
            class="com.thalys.localys.model.Mission"
        />
    </set>
    <!-- bi-directional one-to-many association to Mission -->
    <set
        name="missionsByCptTrajet2"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="CPT_TRAJET2" />
        </key>
        <one-to-many
            class="com.thalys.localys.model.Mission"
        />
    </set>
    <!-- bi-directional one-to-many association to Train -->
    <set
        name="trains"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="CPT_TRAJET" />
        </key>
        <one-to-many
            class="com.thalys.localys.model.Train"
        />
    </set>

</class>
</hibernate-mapping>


When I run the query with only 'trainRame.comp_id.train.trajet.circulation = ? ' in my where clause. Everything is OK but if I add 'trainRame.comp_id.train.trajet.circulation.startDate >= ? and and 'trainRame.comp_id.train.trajet.circulation.stopDate <= ?', It fails.

If somebody has an idea of the problem??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.