Yes that's the other way arround.
Maybe in a IUserType. My advice is take care on isolations levels.

2010/1/4 Tyler Burd <[email protected]>

>  What I generally do when this is a requirement is have an accumulator
> table that holds the next number in the sequence.  When I need to fetch the
> next number, I do this:
>
>
>
> Ensure a transaction exists
>
> Lock the row with the number I need (via LockMode.Upgrade)
>
> Read the number
>
> Increment the number
>
> Set the number on my domain object
>
> Commit the transaction
>
>
>
> This ensures that there are no gaps in the number sequence, as if the
> transaction fails and rolls back the next transaction will be able to pick
> up where the last successful transaction left off.
>
>
>
> *From:* [email protected] [mailto:[email protected]] *On
> Behalf Of *Tuna Toksoz
> *Sent:* Monday, January 04, 2010 9:14 AM
> *To:* [email protected]
> *Subject:* Re: [nhusers] Advice : Generate number
>
>
>
> This kind of key generation sounded like a business concern to me.
> Thoughts?
>
> Tuna Toksöz
> Eternal sunshine of the open source mind.
>
> http://devlicio.us/blogs/tuna_toksoz
> http://tunatoksoz.com
> http://twitter.com/tehlike
>
>
>
>  On Mon, Jan 4, 2010 at 6:01 PM, José F. Romaniello <
> [email protected]> wrote:
>
> A web application is a very concurrent environment, so you will need some
> kind of pessimistic lock. Instead of handling this at application level, I
> would choose doing this work in the database. Where? in a trigger :)
>
> Then set both Update and Insert as false for the column.
>
>
>
> 2010/1/4 Kris-I <[email protected]>
>
>
>
> Hello,
>
> I have to generate an "invoice number", this number has the fomat YYYY/XXXX
> (YYYY  is the year), XXXX is a number. The XXXX must be number without hole
> (1,2,3,4, ...) and no (1,3,4,..).
>
> It's a web application, is there a best practice to do this with NH ?
>
> Thanks,
>
> --
>
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
>
> --
>
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
>
> --
>
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>

--

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