Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate selecting all rows of a table (using .* ) join with multiple tables, giving Exception

Tags:

join

hibernate

Is possible with Hibernate do this?

select A.something, B.something, C.something, D.something , E.*  
      from  A  
      LEFT OUTER JOIN B on A.id = B.id_fk  
      LEFT OUTER JOIN C ON B.id = C.id_fk  
      LEFT OUTER JOIN D ON C.id = D.id_fk  
      LEFT OUTER JOIN E ON A.abc = E.abc;  

This query works fine in SQL but gives below Exception in Hibernate:

org.hibernate.hql.ast.QuerySyntaxException: expecting IDENT, found '*' near line 1
like image 430
sunny_dev Avatar asked Apr 06 '12 08:04

sunny_dev


Video Answer


1 Answers

you don't need the "*". hibernate is turning objects , * is meaningless as its for pointing the columns in SQL. When you want the E , it turns the E object.

SELECT E FROM E

this is the HQL for SELECT * FROM E

even "FROM E" works , when you're calling session.createQuery() .

like image 81
kommradHomer Avatar answered Oct 10 '22 04:10

kommradHomer