-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with transaction rollback
PostPosted: Mon Aug 13, 2007 7:04 am 
Newbie

Joined: Mon Aug 13, 2007 6:48 am
Posts: 2
Hi,

currently i`m working with NHibernate 1.2 and with a MySQl Database 5.
My mapping for an entity called Host is
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="UtilSQL.Host, UtilSQL" table="host">
    <id name="Id">
      <generator class="identity"/>
    </id>
    <property name="HostName" unique="true" not-null="true" column="HostName" type="String" length="255" />
  </class>
</hibernate-mapping>

and i`m opening the connection as follows:
Code:
NHibernate.Cfg.Configuration hibConfig = new NHibernate.Cfg.Configuration();
hibConfig.SetProperty("hibernate.show_sql", "true");
hibConfig.SetProperty("hibernate.dialect",  NHibernate.Dialect.MySQLDialect");
hibConfig.SetProperty("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider");
hibConfig.SetProperty("hibernate.connection.connection_string", "Server=localhost;Database=test;User ID=root;Password=;CharSet=utf8");


Now i try to insert a new Host to my database and force a rollback of a transaction for testing purpose. I`m doing this with the following code
Code:
ITransaction trans = myHibernateSession.BeginTransaction();
Host h = new Host("testHostName");               
myHibernateSession.Save(h);
trans.Rollback();

Normally i expect that there is no entry generated in the database but it is!
So whats wrong here?

If you need any more information let me know.

Thx t2x


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 7:14 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hello,

What is the table type? InnoDB, BerkeleyDB, or some other type ?
If I remember correctly, not all mySQL table types support transactions. Maybe there's the problem, because your code sample looks allright to me.

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 7:24 am 
Newbie

Joined: Mon Aug 13, 2007 6:48 am
Posts: 2
Ahhhhh,
you were right xasp.
The table type was set to MyIsam during the SchemaExport.
As soon as i switched to InnoDB the code above is working ;-)
Thank you very much


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