Hi Fabio - thanks for the reply. I'll investigate the generated
tag.   :-)

Thomas

On 19 Apr., 21:52, Fabio Maulo <[email protected]> wrote:
> If you want maintain something similar to the existing behavior you can use
> the <generated> tag.If you want move the logic outside the RDBMS well... you
> should do some other thing before save the Product, if you want do that
> without touch your classes the PreInsert event is a good place where start.
>
> 2009/4/19 Thomas Koch <[email protected]>
>
>
>
>
>
>
>
> > One more bit of detail, that I have omitted.
>
> > The application is a web app using the open-session-in-view pattern.
>
> > The consequence of this is that the NHibernate transaction is commited
> > when the request is finished. Given this architecture I cannot very
> > easily do an insert first, and then run an update afterwards to set
> > the ProductNumber.
>
> > Thomas
>
> > On 19 Apr., 21:32, Thomas Koch <[email protected]> wrote:
> > > Hi Fabio - thank you for your reply.
>
> > > Alas, I do not see the solution, that you are seeing.  :-)
>
> > > A little bit more detail:
> > > The Product table is mapped to a domain object using NHibernate.
>
> > > When I have to create new instances I create new Product instance I
> > > add them to a ProductList property of a Supplier object, and then I
> > > use cascading persistence to have the Products inserted in the
> > > database.
>
> > > Cheers,
> > > Thomas
>
> > > On 19 Apr., 21:21, Fabio Maulo <[email protected]> wrote:
>
> > > > re-read your first phrase... than think about where put that thing ;)
>
> > > > 2009/4/19 Thomas Koch <[email protected]>
>
> > > > > Hi - I am working on a legacy database, moving business logic from SP
> > > > > to domain objects relying NHibernate.
>
> > > > > I have encountered the following in a SP used to insert a "Product"
> > > > > row:
>
> > > > > DECLARE @productNumber int
> > > > > SET @productNumber = (SELECT isnull(MAX(ProductNumber), 401100) +1
> > > > > FROM Product)
>
> > > > > INSERT INTO Product (
> > > > >  .... [ProductNumber] ...
> > > > > )
> > > > > VALUES (
> > > > >  .... @productNumber
> > > > > )
>
> > > > > I do not think its pretty, but is there anyway I can reproduce this
> > > > > with NH ?
>
> > > > > I am not even sure the existing solution does not contain a race
> > > > > condition.
>
> > > > > Cheers,
> > > > > Thomas
>
> > > > --
> > > > Fabio Maulo- Skjul tekst i anførselstegn -
>
> > > > - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
>
> > > - Vis tekst i anførselstegn -
>
> --
> Fabio Maulo- Skjul tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -
--~--~---------~--~----~------------~-------~--~----~
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