-->
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.  [ 1 post ] 
Author Message
 Post subject: Transaction problem, please help
PostPosted: Fri Apr 29, 2005 1:37 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:3.0[/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():
.......
try
{
session = HibernateUtil.currentSession();
Query query = session.createQuery("FROM User u where u.name =
:name AND u.password = :password");
query.setParameter("name", new String(name));
query.setParameter("password", new
String(computePasswordHash(password)));
user = (User)query.uniqueResult();

Date today = Calendar.getInstance().getTime();
if (user != null)
{
setName(user.getName());
setDescription(user.getDescription());
setPassword(user.getPassword());
setIsAdmin(user.isIsAdmin());
setLoginDate(user.getLoginDate());
setLockedDate(user.getLockedDate());
setLastIp(user.getLastIp());

// transaction starts, updating row in datase
tx = session.beginTransaction();
status = STATUS_VALID;
user.setLoginDate(today);
user.setLastIp(lastIp);
session.save(user);
tx.commit();
// transaction ends
}
else // No user found
status = STATUS_INVALID;
}
catch (Exception e)
{
if (tx != null)
tx.rollback();
throw new Exception(e.getMessage());
}
finally
{
HibernateUtil.closeSession();
}


[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:postgresql 8.0[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]

My problem is that I have transactions which are pending in Posgresql log. Consequently am unable to access my database. Can anyone please tell me what's wron in the code.

thanks in advance


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

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.