Gusti Arya
Gusti Arya

Reputation: 1301

Hibernate cannot run this hql query

I have this query

select faktur.* from
(select a.no_do, a.no_faktur, b.dlr_nama, a.crea_date from honda_h100_fakdos a, honda_h000_dealers b where a.kd_dlr=b.kd_dlr and a.status<>'X' and a.do_tahun>='2012') faktur 

it's running without problem on my SQL manager, but i always getting this error message when I convert this SQL to HQL.

"expecting IDENT, found '*' near line 1"

below is my HQL

select f.* (select a.noDo, a.noFaktur, a.creaDate from HondaH100Fakdos a where a.status <> 'X' and a.doTahun >= '2012' and a.doBulan = '02')  f

I am still a beginner in Hibernate and Java.

Can somebody explain why Hibernate cannot translate this query to HQL?

Upvotes: 1

Views: 403

Answers (2)

SongGuang
SongGuang

Reputation: 71

For example:

db entity :

public class User{

int id;

String name;

// setter and getter
}
db table name : tn_user
       column : tn_id,tn_name

hql : "from User where id=? and name=?" 

? is parameter

Upvotes: 2

Diego Pino
Diego Pino

Reputation: 11596

I think you're missing a FROM after SELECT:

select f.* from (select a.noDo, a.noFaktur, a.creaDate 
from HondaH100Fakdos a 
where a.status <> 'X' and a.doTahun >= '2012' and a.doBulan = '02') f

In any case, this subselect is useless here. This will get you the same result:

select a.noDo, a.noFaktur, a.creaDate 
from HondaH100Fakdos a 
where a.status <> 'X' and a.doTahun >= '2012' and a.doBulan = '02'

Upvotes: 0

Related Questions