-->
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.  [ 4 posts ] 
Author Message
 Post subject: SQLException:You cannot commit during a managed transaction!
PostPosted: Thu Sep 30, 2004 7:21 am 
Newbie

Joined: Thu Sep 30, 2004 6:48 am
Posts: 2
Hello

I


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 30, 2004 12:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I am assuming this is pertinent http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-id-hilo

But I cannot be certain as you really haven't provided any details.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 01, 2004 3:59 am 
Newbie

Joined: Thu Sep 30, 2004 6:48 am
Posts: 2
You are right.

This information was missing in the previous post:

Code:
package es.ameba.gtsp.onetoone;

/**
* @hibernate.class
*/
public class Street {
   private String name;
   private int number;
   private Long id;
   
   public Street() {}
   public Street(String name, int number) {
      this.name = name;
      this.number = number;
   }
   /**
    * @hibernate.id
    *   generator-class="hilo"
    *   unsaved-value="null"
    */
   public Long getId() {return id;}
   public void setId(Long id) {this.id = id;}
   
   /**
    * @hibernate.property
    */
   public String getName() {return name;}
   public void setName(String name) {this.name = name;}
   /**
    * @hibernate.property
    */
   public int getNumber() {return number;}
   public void setNumber(int number) {this.number = number;}
   
   public String toString() {
      return name +" " + number;
   }
   
}


I have changed generator_class to:

Code:
   /**
    * @hibernate.id
    *   generator-class="identity"
    *   unsaved-value="null"
    */


recreated the table in MySql, activated "auto_increment", and now it's working fine.

Now we can start to replace our EJB entity beans with hibernate ;-)

A lot of thanks.
German R.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 5:12 pm 
Regular
Regular

Joined: Thu Jan 29, 2004 10:34 am
Posts: 52
Location: Austin, TX
The simplest case where anyone will get this exception is when you have an EJB configured to do container managed transactions. under jboss any commit to a transaction thus obtained in the code will throw the above exceptoin.

if you are not working with entity beans and want to use transactions in service code that backs the EJB, configure it to use bean managed transactions.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.