-->
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: Native SQL
PostPosted: Mon Nov 29, 2004 9:07 pm 
Newbie

Joined: Mon Nov 29, 2004 9:04 pm
Posts: 4
hi, whu this query does not work ? :
Query q = session.createSQLQuery("SELECT {mot.*} FROM t_mot {mot}" +
"where {mot.intitule} = 'baum'", "mot" , Mot.class);
result = (ArrayList) q.list();



thx a lot ?

error msg :
Caused by: java.sql.SQLException: Syntax error or access violation message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'intitule0_ = 'baum'' at line 1"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
... 18 more


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 30, 2004 3:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh - where is:

- mapping file
- src code
- acutal sql code executed
- ...
- ...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 30, 2004 2:09 pm 
Newbie

Joined: Mon Nov 29, 2004 9:04 pm
Posts: 4
Here is the snippet of hibernate :

<class name="business.entities.Mot" table="t_mot">
<id name="id" column="id" type="long">
<generator class="increment" />
</id>
<discriminator column="t_mot_type" type="string"/>
<property name="intitule" column="intitule" type="string" not-null="true"/>
<property name="genre" column="genre" type="string" not-null="false"/>
<subclass name="business.entities.MotFr" discriminator-value="francais"/>
<subclass name="business.entities.MotAn" discriminator-value="anglais"/>
<subclass name="business.entities.MotAl" discriminator-value="allemand"/>
<subclass name="business.entities.MotEs" discriminator-value="espagnol"/>
</class>

and here is the query that doesn't work :
Query q = session.createSQLQuery("SELECT {mot.*} FROM t_mot {mot} where {mot.intitule} = 'baum'", "mot" , Mot.class);
result = (ArrayList) q.list();

Thx a lot


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 30, 2004 2:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
why don't you post the generated SQL if max already asks for it ... have a look at that, and if you cant find the error yourself, post it.


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.