hibernate query not giving the expected result
**I want to read the users based on there firstname match with passed character I wrote Hibernate Criteria query for same but its not giving me the output it returns 0 rows` ProjectionList projections = Projections.projectionList() .add(Projections.id().as("id")) .add(Projections.property("firstName").as("firstName")) .add(Projections.property("lastName").as("lastName"))
long a=4;
Criteria cr = session.createCriteria(UserInfo.class)
.createAlias("blist", "embeddedObj")
.add(Restrictions.ilike("firstName",name))
.add(Restrictions.ne("embeddedObj.userid",a))
.setProjection(projections)
.setResultTransformer(new AliasToBeanNestedResultTransformer(UserInfo.class));
userInfos =(List<UserInfo>)cr.list();` **
here is the sql query genrated by the hibernate for the same
select this_.id as y0_, this_.firstName as y1_, this_.lastName as y2_, from Users this_ inner join USER_BLOCKUSERS embeddedob1_ on this_.id=embeddedob1_.USER_ID where lower(this_.firstName) like ? and![this is the user table![][1]][1] embeddedob1_.userid<>?
'anil' like 'a'
is false. It would be true if the name was a%
, or %a%
, depending on what you want: names starting with a, or names containing a.
下一篇: 休眠查询没有给出预期的结果