java - Result empty on setting projection for Hibernate criteria -


i have join query want put in programs hibernate criteria.

select a.accountname,a.username,b.name account , user b  a.id=b.accountid , b.name '%abc%' , a.username '%def%' 

my criteria :

criteria usercriteria = session.createcriteria(user.class); detachedcriteria accountcriteria = detachedcriteria.forclass(account.class); accountcriteria .add(restrictions.like("name", "%" + def+ "%"));     accountcriteria.setprojection(projections.property("id")); usercriteria.add(property.forname("accountid").in(accountcriteria));     usercriteria.add(restrictions.eq("username", "%" + abc+ "%"));  list tmplist = usercriteria.setprojection(projections.rowcount()).list();                usercriteria.setmaxresults(pagesize); result = usercriteria.list();    

list tmplist showing empty. can list data before:

list tmplist = usercriteria.setprojection(projections.rowcount()).list(); 

what problem in line?

in clause in query show wrote:

b.name '%abc%'  a.username '%def%' 

but in code writing:

restrictions.like("name", "%" + def+ "%") restrictions.eq("username", "%" + abc+ "%") 

if i'm not wrong creates this:

a.name '%def%'  b.username == '%abc%' 

sarajog


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -