-->
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.  [ 9 posts ] 
Author Message
 Post subject: autocommit="true"
PostPosted: Fri Nov 21, 2003 4:27 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 8:02 am
Posts: 45
I have a class Evenement and a class Utilisateur which are mapping into a Evenement's Mysql table and a Utilisateur's Mysql table as following :

<class name="com.cfort.calendrier.Evenement" table="evenement">
<id name="id" column="id">
<generator class="hilo"/>
</id>
<property name="moment" type="string" length="12"/>
<property name="debut" type="string" length="10"/>
<property name="fin" type="string" length="10"/>
<property name="titre" type="string" length="40"/>
<property name="description" type="string" length="200"/>
</class>
<class name="com.cfort.utilisateur.Utilisateur" table="utilisateur" >
<id name="identifiant" column="identifiant" type="string" length="20">
<generator class="assigned"/>
</id>
<property name="dateAbonnement" type="date"/>
<property name="datePaiement" type="date"/>
<property name="modeReglement">
<column name="modeReglement" sql-type="varchar(30)"/>
</property>
<property name="nbPoints" type="integer"/>
<set name="evenements">
<key column="utilisateur_numero"/>
<one-to-many class="com.cfort.calendrier.Evenement"/>
</set>
</class>

When i insert a evenement with the code as below :

public void insererEvenement(Evenement evt) {
try
{
Session session = HibernateDAOFactory.creerConnection();
Transaction tx = session.beginTransaction();
boolean toggleAutoCommit = session.connection().getAutoCommit();
System.out.println("Valeur de toggle" + toggleAutoCommit);
session.save(evt);
tx.commit();
}
catch(Exception e)
{
e.printStackTrace();
}

}
[/code]

i have the error :

java.sql.SQLException : can't call commit when autocommit=true

while the toggleAutoCommit's value return false

Can you explain to me what wrong because this kind of code works well
in others circumstances


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 6:43 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 8:02 am
Posts: 45
I would like to specify


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 7:34 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read this:

http://forum.hibernate.org/viewtopic.php?t=925718

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 8:52 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 8:02 am
Posts: 45
christian wrote:


I read this and done it but it does not work.
The method getAutoCommit() return false but i have always the message
can't call commit when autocommit=true

WHY ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 8:59 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Then, if getAutoCommit() returns false, and you get an Exception saying that autocommit is on, the return value of getAutoCommit() is not correct? Please, try to verify this problem without Hibernate. I don't know where to continue, also because you don't show the full stack trace of your error.

Try a better database with real transaction support.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 9:11 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 8:02 am
Posts: 45
which i don't understand is that the code i have written works well in the context of the application with others objects map in the same database.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 9:17 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Try to isolate the problem by removing all unnecessary code.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: same problem but got it fixed
PostPosted: Thu Feb 26, 2004 11:00 am 
Newbie

Joined: Thu Feb 26, 2004 10:56 am
Posts: 1
Location: india
I had a similar problem but it got fixed when i changed the generator from hilo to "identity".

Any clue?

cheers
sushil


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 11:34 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
As per the doc, hilo algorithm cannot be used within Tx context

_________________
Emmanuel


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