"The problem is TablePerClass objects that link into it, these all have their own PK" *The POID should, at least, be unique in the same hierarchy, at most should be unique in the whole domain.*
On Tue, Apr 12, 2011 at 12:13 PM, MattE <[email protected]>wrote: > Thanks for the reply. > > The movement table is TablePerClassHierarchy and has a unique PK > called MovementId. The problem is TablePerClass objects that link into > it, these all have their own PK which provide the FK DocLineId on > movement table. So the FK on movement table may be duplicated between > different classes, which is why I was expecting it would check the > Type field which is my discriminator. > > Are you saying that each table that may link into movement table would > need to share the same PK sequence even if they are not in the same > class hierarchy ? > > Thanks > > Matt > > On Apr 12, 3:23 pm, Fabio Maulo <[email protected]> wrote: > > The POID should, as least, be unique in the same hierarchy. > > Using TablePerClassHierarchy the PK is the same for the whole hierarchy > that > > mean you can't have {ID=1, Discriminato="A"} and {ID=1, Discriminato="B"} > > so... the discriminator is unneeded. > > > > On Tue, Apr 12, 2011 at 10:29 AM, MattE < > [email protected]>wrote: > > > > > I noticed in log file the following SQL for my > > > SalesInvoiceLine.Movements collection of SalesMovement objects > > > > > > NHibernate.Persister.Collection.AbstractCollectionPersister.LogStaticSQL(c: > > > \DotNet\NHibernate\NHibernateSource\nhibernate\src\NHibernate\Persister > > > \Collection\AbstractCollectionPersister.cs:572) - One-shot delete: > > > UPDATE Movement SET DocLineId = null WHERE DocLineId = ? > > > > > This could reset more records than I was expecting as it does not > > > check the discriminator column, and the DocLineId holds Id's from > > > different tables. > > > > > Have I missed an option or do I need nHibernate fixed or am I heading > > > down a path of pain with my design ? Needless to say I am stuck with > > > legacy database and can only make limited alterations. > > > > > The product movement table holds PurchaseMovement and SalesMovement > > > records which link to Purchase Invoice lines and Sales Invoice lines, > > > stored in PInvLine and SInvLine tables. The DocLineId is the > > > InvoiceLineId from the applicable table so that SQL statement would > > > clear both if the same ID happened to exist in both PInvLine and > > > SinvLine table. The SalesInvoiceLine uses the following mapping:- > > > > > HasMany<SalesMovement>(x => > > > > > > x.Movements).KeyColumn("DocLineId").Table("Movement").Cascade.SaveUpdate().AsSet(); > > > > > Thanks > > > > > Matt > > > > > -- > > > 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. > > > > -- > > Fabio Maulo > > -- > 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. > > -- Fabio Maulo -- 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.
