-->
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.  [ 1 post ] 
Author Message
 Post subject: SQLGrammarException
PostPosted: Tue Jun 28, 2005 4:35 am 
Newbie

Joined: Wed Jun 15, 2005 9:49 am
Posts: 12
hi,
I'm a beginner in hibernate, I want to make a query between 3 classes:
thanks for any help of a sample code or a useful link or solution of my program.

this query works correctly:
Query query =session.createQuery("select new general.Kharid(p.product_id , p.name , p.price , q.quantity) from general.Quantity as q join q.product_id as p ");

when I change it , error accurs:
Query query =session.createQuery("select new general.Kharid(p.product_id , p.name , p.price , q.quantity) from general.Quantity as q join q.product_id as p join q.customer_id as c ");

java.lang.RuntimeException: net.sf.hibernate.exception.SQLGrammarException: Could not execute query
...
Caused by: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'quantity0_.product_id=product1_.product_id inner join app_customer user2_ on quantity0_.customer_id=user2_.customer_id'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLPrepare(JdbcOdbc.java:4784)
at sun.jdbc.odbc.JdbcOdbcConnection.prepareStatement(JdbcOdbcConnection.java:475)
...

Quantity.hbm contains:
<many-to-one name="customer_id" class="general.User" column="customer_id" />

<many-to-one name="product_id" class="general.Product" column="product_id" />

and user.hbm & product.hbm contain <set >...
for product.hbm :
<set name="pquantity" table="app_intersect" cascade="all" inverse="true" lazy="true">
<key column="product_id"/>

<one-to-many class="general.Quantity" />

</set>

this query also works correctly:
Query query =session.createQuery("select new general.Kharid(p.product_id , p.name , p.price , pq.quantity) from general.Product as p join p.pquantity as pq , general.User as u join u.cquantity as c where pq.product_id=2");


when I change it, 1 error occurs in compiling it's file :
Query query =session.createQuery("select new general.Kharid
(p.product_id , p.name , p.price , pq.quantity) from general.Product as p join p.pquantity as pq , general.User as u join u.cquantity as c where u.username= ?", username , Hibernate.STRING);

UserService.java:209: createQuery(java.lang.String) in net.sf.hibernate.Session
cannot be applied to (java.lang.String,java.lang.String,net.sf.hibernate.type.Nu
llableType)
Query query =session.createQuery("select new general.Kharid
^
(p.product_id , p.name , p.price , pq.quantity) from general.Product as p join p.pquantity as pq , general.User as u join u.cquantity as c where u.username= ?", username , Hibernate.STRING);

1 error

thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.