These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: some times , hibernet select query return null
PostPosted: Fri Apr 23, 2010 3:24 am 
Newbie

Joined: Fri Apr 23, 2010 3:12 am
Posts: 1
Hi,

Some times hibernaet return null for select query, although table contain data.

May I know why it is happening, I tried a lot but couldn't get any solution for it.
My code is as follows


String query = "select usr from User usr where usr.email3= :email and AGENT=:agt";
String[] parmaNames = new String[2];
Object[] parmaValues = new Object[2];
parmaNames[0] = "email";
parmaValues[0] = email.toLowerCase();
parmaNames[1] = "agt";
parmaValues[1] = "I";
List uList = getHibernateTemplate().findByNamedParam(query, parmaNames, parmaValues);

if(uList == null || uList.size()==0 ){
if(email != null){
logger.info("Case for email as loginid email_id :"+email+" and its length is :"+email.length());
}
return null;
}else return (User)uList.get(0);



Thanks in advance


Top
 Profile  
 
 Post subject: Re: some times , hibernet select query return null
PostPosted: Fri Apr 23, 2010 5:15 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
An possible explanation could be that the table contain uncommted data
and you access the database with READ_COMMITED isolation level (=default).

Anyway I suggest you to log the queries (and the regarding result-set) with p6spy.
It helps a lot to undestand if the cause is in hibernate or elsewhere (jdbc-driver , database , etc.)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.