instead of:
Quote:
Code:
public User getUser(String username)
{
User user=null;
try
{
user = (User)getHibernateTemplate().createQuery("from User user where user.username like '"+username+"'").uniqueResult();
user.setEmail("abcd@yahoo.com");
getHibernateTemplate().update(user);
}
catch (Exception e)
{
e.printStackTrace();
}
return user;
}
use:
Code:
public User getUser(final String username)
{
User user= (User) hibernateTemplate.execute(
new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
User user = session.createQuery("from User user where user.username like '"+username+"'").uniqueResult();
user.setEmail("abcd@yahoo.com");
session.update(user);
return user;
}
}
);
return user;
}
Haven't test it - but you should get an idea.
Lukasz[/quote]