What Fabio meant: Move the business logic to the domain objects, not the domain object's NHibernate mappings.
-Markus 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 - > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
