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 at http://groups.google.com/group/nhusers?hl=en.
