In my MySql database i have a field which is a timestamp. MySQL is inserting the time when the row is created and updates the time when a row is updated.
How do I tell NH开发者_JAVA技巧ibernate don't to insert anything in that field when inserting and updating. I still want to be able to read the property.
With my current mapping:
Map(x => x.CreateDate).Column("CreateDate");
NHibernate tries to insert 0001-01-01 00:00:00, because the field is not nullable (And it should not be nullable)
I'm using Fluent Nhibernate.
I believe you should be able to add ReadOnly()
to get that effect.
Map(x => x.CreateDate).Column("CreateDate").ReadOnly();
I guess you should specify that property is generated by database:
Map(x => x.CreateDate).Column("CreateDate").Generated.Always();
精彩评论