Sushil Kumar :
Here, I am joining two tables and get it in List<Confrenceresponse>
, But I don't know why my all the list gives only first data in mutiple time(size of list get by query).
public List<ConferenceResponse> getConferenceResponse(long listId) {
String hql = "select e.contact as contact, e.name as name, e.ueId as ueId, c.created as created from ExcelDatas e left join
channels c on e.contact=c.cid_num where e.ueId = "+listId;
List<ConferenceResponse> confRe =(List<ConferenceResponse>)getSession().createNativeQuery(hql, ConferenceResponse.class).getResultList();
for(ConferenceResponse cr:confRe) {
System.out.println("Name "+cr.getName());
}
getSession().flush();
return confRe;
}
Here, if I am getting 3 join data from table I get first data repeated three times. Can any one solve this? Thanks.
Pooja Aggarwal :
Change your HQL to the below one. Also, HQL does not support on keyword.
String hql = "select e.contact as contact, e.name as name, e.ueId as ueId, c.created as created from ExcelDatas e left join
e.contact c where e.ueId = "+listId;
If you do not have relationships in entity class, you need to make cross join as follows.
String hql = "select e.contact as contact, e.name as name, e.ueId as ueId, c.created as created from ExcelDatas e,channels c where e.contact=c.cid_num and e.ueId = "+listId;