Advertisement

07.19.2008 at 02:14PM PDT, ID: 23579451 | Points: 250
[x]
Attachment Details

HIbernate and active transaction

Asked by user6246 in Java Servlets

Tags: JAVA, Caused by: org.hibernate.HibernateException: createCriteria is not valid without active transaction, JAVA Hibernate Mysql

hi,

context : tomcat + hibernate + mysql
i have an irregulat error that occur in the login process of my application,  i try to get the user information from the datababe.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
public User getUserByLogin(String login) throws FunctionnelException {
        
    try {
       session = SessionFactory.getCurrentSession();
       transaction = session.beginTransaction();
       final User user = (User) session.createCriteria(User.class).add(Expression.eq("username", username)).uniqueResult();
         transaction.commit();
         return user;
        }
.....
[+][-]07.22.2008 at 01:39AM PDT, ID: 22057274

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 03:32AM PDT, ID: 22057737

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.28.2008 at 09:55AM PDT, ID: 22337040

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628