Temporary data using NHibernate

Can someone provide some tips / pointers / links on how to implement a temporary state table with NHibernate? Ie, each entity table has start_date and end_date columns that describe the time interval in which this row is considered valid.
When the user inserts a new object, start_date gets "now" and end_date will be null (or date far into the future, I haven't decided yet).
When upgrading, I would like to change the UPDATE query to the following:

  • UPDATE end_date for this line of entities and
  • INSERT a new line with the current date / time and zero end_date.

I tried using event listeners to manually write an UPDATE query for 1, but cannot figure out how to implement a new INSERT query for 2.

Is this the right way? Or am I completely not marked here?

+3
source share
4 answers

In fact, we have a working solution, I work, but it effectively kills part of the nhibernate mechanism.

For "temporary objects" NH acts only as an insertion / selection mechanism. Uninstallations and updates are performed using another utility in which the NH ORM part is convenient.

, nhibernate, , , . , , , .

, datetime . ( 16.1 NH ref, , BETWEEN), , , NH . http://savale.blogspot.com/2010/01/enabling-filters-on-mapped-entities.html .

, "where" ( ), , , "where" ( , ).

, / , http://www.cs.arizona.edu/~rts/publications.html

, NULL _end, ( NOT-NULL, , ISNULL).

, _end, , _start , _end

+2
+1

, - - Java (, Java), NHibernate . , "" "", . UserType .

0

, . , , .

0

Source: https://habr.com/ru/post/1721278/


All Articles