I need get all data from relative table so I'm using something like this (i would use it in sql)
private static final String SELECT_OOPR_TO_SEND = "SELECT R.* " +
"FROM offerOrderProjectRel R, offerOrder O, project P " +
"WHERE P.id = R.project_id and O.id = R.offer_order_id " +
"and O.type = 'ORDER' and (P.status = 'PENDING' or P.status ='PROTECTED')" ;
;
@SuppressWarnings("unchecked")
public List<OfferOrderProjectRel> findAllOfferOrderToSendToSalesmans() {
Query q = getSession().createQuery(SELECT_OOPR_TO_SEND);
List<OfferOrderProjectRel> list = q.list();
return list;
}
After lauching this code i'm getting that error :
org.hibernate.hql.internal.ast.QuerySyntaxException: expecting IDENT, found '**' near line 1, column 10 [SELECT R.* FROM offerOrderProjectRel R, offerOrder O, project P WHERE P.id = R.project_id and O.id = R.offer_order_id and O.type = 'ORDER' and (P.status = 'PENDING' or P.status ='PROTECTED')]
So how can I obtain all data from column R with hibernate?
The method createQuery
expects an HQL query string.
HQL is an object-oriented querying language.
HQL interprets SELECT R.*
as select the member field *
of the object R
.
But *
is not a member field of R
. Is it?..
To select all the member fields of R
use:
SELECT R
FROM offerOrderProjectRel R, offerOrder O, project P
WHERE P.id = R.project_id and O.id = R.offer_order_id
and O.type = 'ORDER' and (P.status = 'PENDING' or P.status ='PROTECTED')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With