-->
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.  [ 1 post ] 
Author Message
 Post subject: TimeStamp Column in Microsoft SQL 2005
PostPosted: Thu Mar 26, 2009 6:34 am 
Newbie

Joined: Sat Jun 10, 2006 10:24 am
Posts: 16
Hi Nhibernate Users!

I have a small issue with using the time stamp column in SQL server 2005 when I run the schemaexport code, its creates the timestamp as a DateTime field, which if course causes my inserts to fail.

Anyone know how I can get nhibernate to create the table using "Timestamp" rather than "DateTime" for the columns defined as "Timestamp"?

If not how are other people implement concurrency management on SQL Server 2005?

This is the code that creates the DB fromt he schema files:

Code:

// Rebuild the database tables according to the schema files.
SchemaExport SchemaExport = new SchemaExport(_unitOfWorkFactory.Configuration);

// Execute the schema update.
SchemaExport.Execute(script, export, justDrop, format);


NHibernate version::2.0.50727

Mapping documents::

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="TEST.DataAccess.Tests" namespace="TEST.DataAccess.Tests">
<class name="TestPerson" optimistic-lock="version">
<id name="Id">
<generator class="guid"/>
</id>
<version column="Version" type="Timestamp" name="Version" unsaved-value="null" generated="always" />
<property name="Name" not-null="true" length="50"/>
<property name="Birthdate" not-null="true"/>
</class>
</hibernate-mapping>

Name and version of the database you are using:

Microsoft - SQL Server 2005

The generated SQL (show_sql=true):

NHibernate: INSERT INTO [Test].[dbo].TestPerson (Name, Birthdate, Id) VALUES (@p0, @p1, @p2); @p0 = 'John Doe', @p1 = '15/12/1915 12:00:00 AM', @p2 = '10c27ab9-75d5-4351-ab4d-4cd04a439b7c'
[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.