Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate HQL issue expecting IDENT found "*"

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?

like image 735
lukaszrys Avatar asked Oct 22 '13 14:10

lukaszrys


1 Answers

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')
like image 119
user2845946 Avatar answered Oct 11 '22 11:10

user2845946