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; 

see example here or here

then use join , in hql or hibernate criteria


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -