-->
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: net.sf.hibernate.QueryException:
PostPosted: Fri Apr 29, 2005 11:56 am 
Newbie

Joined: Tue Jan 04, 2005 11:06 am
Posts: 15
From the stack trace below, you will see I get the following error:

net.sf.hibernate.QueryException: in expected: d [select from AssetDetail d where d.irn = :irn]

I have tried many variatons (e.g. removing select, not providing an alias), all with the same message.

I am doing similar things with other persistent objects, with no problem.
I can't see what is different here. Perhaps, I am missing something obvious.

Any ideas?

Thanks
Rob



Hibernate version: 2.1.6

Mapping documents:

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>
<class
    name="com.trustetc.model.AssetDetail"
    table="TRALOGSL1" >
    <meta attribute="class-description" inherit="false">
       @hibernate.class
        table="TRALOGSL1"
    </meta>
                                                                                                                                             
    <id type="java.lang.Integer" column="id" unsaved-value="null" >
        <meta attribute="field-description" inherit="false">
           @hibernate.id
            generator-class="native"
         </meta>
      <generator class="native"/>
    </id>
        <property
            name="irn"
            column="CUSIP#"
            type="java.lang.String"
            length="9" >
            <meta attribute="field-description">
               @hibernate.property
                column="CUSIP#"
            </meta>
        </property>
        <property
            name="detailLine"
            column="INAMES"
            type="java.lang.String"
            length="35"
        >
            <meta attribute="field-description">
               @hibernate.property
                column="INAMES"
            </meta>
        </property>
</class>
<hibernate-mapping>




Code between sessionFactory.openSession() and session.close():
Code:
public List getAssetDetailsByIrn(String irn)  throws Exception {
                                                                                 
    Vector details = new Vector();
    Session s = getSession();
    try {
      Query query = s.createQuery(getAssetDetailsByIrnQueryString);
      details.addAll(
       query.setParameter("irn", irn, Hibernate.STRING).list());
    } catch (Exception e) {
       logger.warn("Could not get asset description lines for IRN " + irn);
       e.printStackTrace();
       throw new Exception (e);
    } finally {
       s.close();
    }
    return details;
}

Full stack trace of any exception that occurs:

Quote:
net.sf.hibernate.QueryException: in expected: d [select from AssetDetail d where d.irn = :irn]
at net.sf.hibernate.hql.FromParser.token(FromParser.java:102)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.trustetc.dao.hibernate.AssetDetailDaoHibernate.getAssetDetailsByIrn(AssetDetailDaoHibernate.java:68)


Name and version of the database you are using: db2 on AS/400

_________________
Rob Gordon
SuffolkSoft, Inc.
Westby, WI


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 29, 2005 12:14 pm 
Newbie

Joined: Wed Oct 27, 2004 3:32 pm
Posts: 3
I think you are missing the 'd'.

select [b]d[/b] from AssetDetail d where d.irn = :irn[/u]


Top
 Profile  
 
 Post subject: net.sf.hibernate.QueryException: (resolved)
PostPosted: Fri Apr 29, 2005 12:29 pm 
Newbie

Joined: Tue Jan 04, 2005 11:06 am
Posts: 15
There is nothing like a good night's sleep to clear the vision...

I am using Spring and I did not have the mapping file for AssetDetail
persistence class defined in the applicationContext.xml file.

Of course, matter were complicated because I did define the class
in hibernate.cfg.xml...which I use for unit test.

Happy Coding.

Rob

_________________
Rob Gordon
SuffolkSoft, Inc.
Westby, WI


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.