java - Hibernate query build -
currently using createsqlquery query model read data database using hibernate. now, want modify query using either hql or hibernate criteria. query looks follows.
select concat(d.area,' ',d.city) location, a.transferred_date actualtransferdate, concat(c.scan_code,',',c.serial_no) scanserialcode, c.model_no modelnum, c.asset_name assetname table_transfer a, table_category b, table_asset c, table_location d a.asset_id = c.asset_id , b.asset_category_id = c.asset_category_id , a.transfer_to_location=d.location_id"
i not sure how can can convert hibernate sql or criterion based query. can 1 me?
you can introduce fields location
, scanserialcode
in entity , mark them @formula
e.g.
@formula("concat(d.area,' ',d.city)") private string location;
then use join , in hql or hibernate criteria
Comments
Post a Comment