开发者

NHibernate update causes a select of a row's computed columns

I've got a User class that I want to update. There's a User table in my database with two columns among others: FirstName and Lastname and there's a computed column called DisplayName that concatenates the two with a space in the middle. The NHibernate mapping for DisplayName is

<property name="DisplayName" type="string" generated="always"/>

When I update the User object and commit the transaction, NHibernate runs an extra select statement just on the DisplayName property, I presume to keep the object and the DB row in sync. I don't need that as the object goes out of scope right afterwards.

Is there something I can do to tell NHibernate that there's no need to get the updated DisplayName at this t开发者_Go百科ime?

Regards, F.


generated="always" means exactly that: "this is a value generated by the DB every time I modify this row; please refresh it for me".

NH does not have a concept like "only refresh this if a particular column changed".

My opinion is that you should generate that value in your domain model instead of the DB.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜