Nhibernate 1.2
Hi,
Sorry for the slight dupe of a previously ignored post, but this strikes me as either a serious problem, or an oversight in the documentation.
I am trying to use <version> in a persistent class to allow for optimistic-locking, collision detection. In my mapping I quite plainly have:
<version column="version" name="version" type="TIMESTAMP" access="field" generated="ALWAYS">
Now, when autogenerating the schema, NHiberate creates a "datetime" SQL type in MySQL. It then DOES NOT auto generate the value. When I change the SQL type in the database to "timestamp" it works correctly on insert.
I tried the other verion types (int, long, etc.) with generated="ALWAYS" and Hibernate sets the value to 0 and never updates it automatically. Including when I leave the generated schema type as "datetime", it is all 0's.
I saw a lengthy discussion about this from 2004 (however I am not using Java), but alas, I expect generated="ALWAYS" to mean the database generates the value, and it does not.
I also expect type "timestamp" to be the equivalent of database column type "timestamp". Since it is the only condition where it actually works, but hibernate does not map to this obvious type.
thanks,
S
[/url]
|