Oh amazing thank you so much!!! That worked like a charm. Adding .id and .class into my google searches allowed me to finally find this in the documentation. In case anyone else reads this, here is where .id and .class are documented:
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-identifier-property (it's for hibernate - but it also applies to nhibernate) >From the documentation: An "any" type has the special properties id and class that allows you to express a join in the following way (where AuditLog.item is a property mapped with <any>): from AuditLog log, Payment payment where log.item.class = 'Payment' and log.item.id = payment.id The log.item.class and payment.class would refer to the values of completely different database columns in the above query. But I couldn't find anything saying if there were any other special properties like that. On May 8, 8:44 am, Fabio Maulo <[email protected]> wrote: > x.MasterEntity.class = "WebpageMaster" > x.Entity.class = "Webpage" > > Note: "class" is lowercase > > > > > > On Fri, May 7, 2010 at 5:38 PM, nicklang <[email protected]> wrote: > > Hi, > > > I'm trying to make an HQL query like this: > > > select a from Audit a > > where > > a.Website.id = :websiteId and > > a.AuditVersion = (select > > max(b.AuditVersion) from Audit b where > > b.AuditVersion <= :version and > > b.MasterEntity.GetType() = > > a.MasterEntity.GetType() and > > b.MasterEntity.id = a.MasterEntity.id) > > group by > > a.MasterEntity.GetType(),a.MasterEntity.id > > > I'm not sure how to get the TYPE of my MasterEntity field in the > > query. I tried to map that column to another field but this causes > > other problems. Obviously calling GetType() is not real (I just > > guessed that) - but is there someway of doing this at all? > > > Here is the mapping (using fluent nhibernate): > > > public class AuditMap : ClassMap<Audit> > > { > > public AuditMap() > > { > > Id(x => x.AuditId) > > .Column("AuditId") > > .GeneratedBy.HiLo("HiLo", "Hi", "1000"); > > Version(x => x.ConcurrencyVersion); > > References<Website>(x => x.Website) > > .Column("WebsiteId") > > .Not.Nullable() > > .Cascade.SaveUpdate(); > > Map(x => x.Created); > > Map(x => x.IsTrunk); > > Map(x => x.IsLive); > > Map(x => x.IsActive); > > Map(x => x.AuditVersion); > > ReferencesAny<object>(x => x.MasterEntity) > > .EntityTypeColumn("MasterEntityType") > > .EntityIdentifierColumn("MasterEntityId") > > .AddMetaValue<WebpageMaster>("WebpageMaster") > > .IdentityType<int>() > > .Cascade.SaveUpdate(); > > ReferencesAny<object>(x => x.Entity) > > .EntityTypeColumn("EntityType") > > .EntityIdentifierColumn("EntityAuditId") > > .AddMetaValue<Webpage>("Webpage") > > .IdentityType<int>() > > .Cascade.SaveUpdate(); > > } > > } > > > -- > > 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. > > -- > 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 > athttp://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.
