Right now I was having a weird issue with a transaction and saving two
entities on a MS-SQL 2000 database OR a SQL compact 3.5 database.
In a nutshell I did the following on both databases
Begin a new transaction
.Save(entity1)
.Save(entity2)
ICriteria Query for the entities
Rollback the transaction
Now what happened in the SQL profiling tool was the following
Transaction was started
select max(id) from entity table
ICriteria Query ran, didn't find anything
Transaction was rolled back
Entity 1 was inserted
Entity 2 was inserted
First I suspected caching to be an issue so I tried putting
<property name="cache.use_second_level_cache">false</property>
or
<property name="adonet.batch_size">1</property>
into the connection XML but that didn't seem to change anything
I'm clueless why the Insert commands seem to fall out of the
transaction.
In my scenario there are two fixes/workarounds.
1: Setting the ID column of the entities table to "Identity" and
changing the generator in the mapping document to
<generator class="identity"></generator>
The Inserts do happen inside the transaction then.
2: Committing the transaction right after the calls to .Save(...)
Same here, the inserts do happen inside the transaction.
If someone needs it, heres the complete mapping document for the class
without the identity workaround
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >
<class name="TrackingFolder.Core.Domain.Folder, TrackingFolder.Core"
table="folder">
<id name="Id" type="int" column="id">
<generator class="increment"></generator>
</id>
<property name="Name" column="name" type="string" />
</class>
</hibernate-mapping>
Here the connection document for SQL 2000:
<?xml version="1.0" encoding="utf-8" ?>
<nhibernate>
<session-factory name="trackingfolder" xmlns='urn:nhibernate-
configuration-2.2'>
<property name="connection.connection_string" >Data Source=xp-
sql2000dev;Initial Catalog=trackingfolder;User
Id=some_user;Password=some_password;</property>
<property
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</
property>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</
property>
<property
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</
property>
<property name="connection.isolation">ReadCommitted</property>
<property
name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory,
NHibernate.ByteCode.LinFu</property>
</session-factory>
</nhibernate>
And here the connection stuff for SQL Compact 3.5:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="trackingfolder">
<property
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</
property>
<property name="dialect">NHibernate.Dialect.MsSqlCeDialect</
property>
<property
name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</
property>
<property name="connection.connection_string">Data
Source=TrackingFolder.sdf</property>
<property
name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory,
NHibernate.ByteCode.LinFu</property>
<property name="connection.isolation">ReadCommitted</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
I guess I'm doing something very wrong but can't figure out what.
Greets
Frank
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.