Hi all,

 

I'm using NH to map a domain that contains some entities that have an
"identification number", it is not a primary key, it's just an id number
that has a meaning for the user. A really simple example is the invoice
number.

 

The important thing is that this id number is always generated and never
assigned by the user. Each entity has its own strategy to generate this "id
number" that has to be generated only at insert time and then is immutable,
which is the best strategy to inject in NH this generation logic? Is an
IInterceptor a viable way?

 

The simplest generation strategy, just for the records, is the "invoice
number":

-          Within a transaction.

-          Just before insert a transient invoice look into invoices table
sorting invoices by number descending and filtering by incoming document
year;

-          Take the top number + 1 if one, otherwise take 1;

-          Assign it to the invoice entity;

-          Commit transaction;

 

I know that I can do all this in my code but I would like to automate the
process at the persistence level.

 

TIA, best regards.

.m


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to