-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with auto-commit
PostPosted: Thu Nov 20, 2003 5:25 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 :
Code:
public void insererEvenement(Evenement evt) {
      try
            {
               Session session = HibernateDAOFactory.creerConnection();
               Transaction tx = session.beginTransaction();
               session.save(evt);
               tx.commit();
            }
            catch(Exception e)
            {
               e.printStackTrace();
            }
      
   }


i have the error :

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

Can you explain to me what wrong because this kind of code works well
for others objects?


You will find here the content of the hibernate.cfg.xml file :

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>


<!-- properties -->
<property name="connection.datasource">java:comp/env/jdbc/portail</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>

<!-- mapping files -->
<mapping resource="utilisateur.hbm.xml"/>


</session-factory>

</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 10:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
See: http://forum.hibernate.org/viewtopic.php?t=925718


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