-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem with the parameterized query in hbm.xml
PostPosted: Mon Feb 06, 2006 3:19 pm 
Newbie

Joined: Mon Feb 06, 2006 2:56 pm
Posts: 2
Hibernate version: 3.0

I make 2 queries as below in log_info.hbm.xml. When I run it, the following exception thrown with the 2nd query. The first qury is correct, and 2rd has problem with "?1". When I move "?1" to a specific value (12), it has no problem.

Who can help me?

Thanks

gzhuye


Query in log_info.hbm.xml:


Code:
   <query name="com.atlantics.atm.db.bean.Log_info.getAllLogInfo"><![CDATA[
            from com.atlantics.atm.db.bean.Log_info
    ]]></query>
    <query name="com.atlantics.atm.db.bean.Log_info.getSearchLogInfo"><![CDATA[
            from com.atlantics.atm.db.bean.Log_info as tbl where tbl.log_info_id = ?1
    ]]></query>


Exception:

Code:
org.hibernate.HibernateException: Errors in named queries: com.atlantics.atm.db.bean.Log_info.getSearchLogInfo
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:302)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:769)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:695)
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 4:46 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
What is "?1" supposed to mean? For a query you can use SQL-style ? parameters (0 based, not 1 based as they are in SQL), or named parmaeters (e.g. ":param1"), but "?1" isn't a parameter.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 6:10 pm 
Newbie

Joined: Mon Feb 06, 2006 2:56 pm
Posts: 2
Thank you very much! I just followed a doc on ibm developer: http://www-128.ibm.com/developerworks/j ... /j-hibern/

something wrong with it, it shouldn't use sql parameters like ?1, ?2....

Regards

gzhuye


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 7:33 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Yes, that article is wrong. Don't forget to rate if you think my answer helped.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 3:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
?1 is actually supported now for ejbql 2.1 good old time sake - but don't use it :)

...but the article is from before that, so yes it is weird.

_________________
Max
Don't forget to rate


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