-->
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: Name SQL Query
PostPosted: Tue Jul 20, 2004 9:25 am 
Regular
Regular

Joined: Tue May 04, 2004 6:15 am
Posts: 51
Hello,

When trying to perform the following query

Code:
<sql-query name="destinationForPort">
    <return alias="destination" class="Location"/>
       SELECT {destination}.DABBR AS {destination.abbreviation},
                 {destination}.DNAME AS {destination.name}
       FROM DESTINATION {destination}, PORTS_FOR_DESTINATION {ports_destinations}
       WHERE {destination}.DABBR = {ports_destinations}.DABBR
       AND {ports_destinations}.PORT_ID = :portAbbreviation
</sql-query>


I get the following exception :(

Code:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Line 5: Incorrect syntax near '{'.
   at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
   at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
   at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
   at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
   at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
   at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
   at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
   at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
   at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
   at net.sf.hibernate.loader.Loader.list(Loader.java:946)
   at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
   at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3802)
   at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)


Thanks

_________________
eu:life
http://www.eulife.gr


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Check the generated SQL in the Hibernate LOG output


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:34 am 
Regular
Regular

Joined: Tue May 04, 2004 6:15 am
Posts: 51
Code:
SELECT destination.DABBR AS dabbr0_, destination.DNAME AS dname0_ FROM DESTINATION destination, PORTS_FOR_DESTINATION {ports_destinations} WHERE destination.DABBR = {ports_destinations}.DABBR AND {ports_destinations}.PORT_ID = ?

_________________
eu:life
http://www.eulife.gr


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Do

Code:
<sql-query name="destinationForPort">
    <return alias="destination" class="Location"/>
       SELECT {destination}.DABBR AS {destination.abbreviation},
                 {destination}.DNAME AS {destination.name}
       FROM DESTINATION {destination}, PORTS_FOR_DESTINATION somealias
       WHERE {destination}.DABBR = somealias.DABBR
       AND somealias.PORT_ID = :portAbbreviation
</sql-query>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:38 am 
Regular
Regular

Joined: Tue May 04, 2004 6:15 am
Posts: 51
worked :/

_________________
eu:life
http://www.eulife.gr


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.