hi Diego, I don't think I can, we want the concrete classes (plug-in module projects) to be persisted in separate tables (witout a common primary key, and as far as i can tell from the documentation this is the only way to do it), so I guess the only way to do this is to store the entity type in a field in the concrete class table like a pseudo-discriminator - that way i can group by it...but seems a little dirty :(
and as the concrete classes are defined in , a, to have a subclass or union subclass the mapping On Fri, May 7, 2010 at 1:21 PM, Diego Mijelshon <[email protected]>wrote: > I believe the .class pseudo-property is not available when using implicit > polymorphism. > Anyway, NHibernate is going to do multiple queries in that case, not > unions, so you might as well do it explicitly (one criteria query per > subclass). > > Have you considered switching to a different inheritance strategy? > > Diego > > > On Fri, May 7, 2010 at 08:27, Jon Moore <[email protected]> wrote: > >> Thanks guys, Diego was quite right - it was totally my issue with having >> incorrect data, I misunderstood the documentation and assumed it was a >> limitation but it was due to my duff data...my fault! >> >> Is there an identifier I can use to identify the type of concrete class in >> an Icritera query, i.e. so I can group by the type and count? something like >> this: >> >> var criteria = session.CreateCriteria(typeof (CoreItem)); >> criteria.SetProjection(Projections.ProjectionList() >> >> .Add(Projections.Property("<<<TYPE>>>"), "Identifier") >> .Add(Projections.Count("Id"), "Result") >> >> .Add(Projections.GroupProperty("<<<TYPE>>"))); >> >> >> >> >> On Thu, May 6, 2010 at 9:01 PM, Diego Mijelshon >> <[email protected]>wrote: >> >>> I don't see why you can't use a different inheritance strategy. >>> NHibernate doesn't care in which assembly your classes are (of course, >>> you'll need to use full type names). >>> >>> Anyway, your query should work. Are you sure you have persistent >>> instances (rows) of both classes? >>> >>> Diego >>> >>> >>> >>> On Thu, May 6, 2010 at 09:40, kmoo01 <[email protected]> wrote: >>> >>>> Hi guys, >>>> From the documentation I can see that implicit polymorphism, in my >>>> case, will not generate SQL UNIONs when performing polymorphic >>>> queries. but is there any way of looping through the concrete classes >>>> and union the results manually? >>>> >>>> My scenario: >>>> >>>> Im using a "Table per concrete class" approach, and I don't hold >>>> instances of the superclass >>>> >>>> Abstract class "CoreItem" (no mapping file needed) >>>> Concrete class "ResearchItem" inheriting from "CoreItem" with mapping >>>> file including all core item properties >>>> Concrete class "TestItem" inheriting from "CoreItem" with mapping file >>>> including all core item properties >>>> >>>> When I query the CoreItem like below I can see 2 queries run correctly >>>> from sqlprofiler, but only the second is returned... >>>> >>>> ICriteria crit = session.CreateCriteria(typeof(CoreItem)); >>>> ..some expressions... >>>> crit.List<CoreItem>(); >>>> >>>> >>>> Unfortunately I need to have the inheritance this way because the 2 >>>> concrete items actually live in separate assemblies, meaning the >>>> abstract class doesn't have any knowledge of them (so cant do a >>>> subclass mapping - as far as im aware...) >>>> >>>> Cheers guys, >>>> kmoo01 >>>> >>>> -- >>>> 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.
