java - How Can I write The Following Query In hibernate Criteria -


select * table left join table b on a.id=b.id , a.langcode='in'; 

where 'in' input user.

table , table b has mapping id there no mapping langcode between 2 table b dosent have column called langcode map , want write following query using hibernate criteria without mapping langcode.

table: employee : emp_id - primary key , name , contact_details

table:employee_lang: emp_id- composite primary key, lang_code- composite primary key, name

actual query:

select * employee emp left outer join employee_lang emplang on emp.emp_id=emplang.emp_id , emplang.lang_code='in' 

i have mapped emp_id primary key both tables in hibernate hence hibernate criteria apply join on , not on langcode.

note:-i cant change hibernate mapping , can use hibernate criteria , per clients requirement, please me on one.

for example have 2 models:

@entity class employee {   @id   private long id;   @onetoone   private employeelang employeelang;   ... } @entity class employeelang {   @id   private long id;   private string langcode;   @onetoone   private employee employee;   ... } 

you should have mapping between them , can next criteria:

criteria criteria = session.createcriteria(employee.class); criteria.createalias("employeelang", "emplang"); // inner join employeelang criteria.add(restrictions.eq("emplang.langcode", "in");  list<employee> employees = criteria.list(); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -