1

As I understand it NHibernate has a build in support for timestamps. However, it appears you can only instruct NHibernate to never update the property or always update it.

In the project I am currently working on there are several tables which have both "created_time" and "updated_time", both are to be generated by the database.

I can't figure out how to instruct NHibernate to use "getdate()" for both properties nut only on insert for "created_time" and on insert and update for "updated_time".

Is this possible?

PS: I am working with a legacy database and I am not allowed to change it, so triggers etc. are not possible solutions.

2 Answers 2

1

You could work around this by creating an Interceptor that sets those values, but offcourse, then those values are not generated by the DBMS offcourse ...

It might be a workaround, as I also don't know how to make sure that the DB populates those values, but I'm also interested in another solution for this issue. :)

Sign up to request clarification or add additional context in comments.

1 Comment

In the end I settled for the interceptor solution, but would be nice if there was a special property for this.
1

Which version of NHibernate are you using?

In 2.0, the "generated" tag on a property has three valid values:

  • never (self-explanatory)
  • insert(will retrieve the generated value only on inserts)
  • always (always retrieves generated value).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.