hi all,
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.