The polymorphism="explicit" trick only works when I make the second mapping for a new class FooAudit : Foo. I understand why it works this way now. This isn't a dead end. It just means I have to get the next feature working before this one will work. Thanks Fabio! Any tips for mapping to a dynamic proxy class?
On Jan 24, 5:08 pm, Fabio Maulo <[email protected]> wrote: > Jason... found the reason... > You are querying one class spanned in two tables and that is the reason > because NH is applying a UNION. > Perhaps, and underling perhaps, the tag polymorphism="explicit" and using > the entity-name in the query can do the trick. > > 2010/1/24 Jason Dentler <[email protected]> > > > > > > > Hi, > > > I have a class: > > > public class foo > > { > > public virtual long Id { get; set; } > > public virtual string Data1 { get; set; } > > public virtual Guid Revision { get; set; } > > // Equals and GetHashCode also implemented > > } > > > with the following mappings: > > > <?xml version="1.0" encoding="utf-8" ?> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > assembly="NHEntityTest" > > namespace="NHEntityTest" > > default-lazy="false"> > > > <class name="Foo"> > > <id name="Id"> > > <generator class="hilo" /> > > </id> > > <property name="Data1"/> > > </class> > > > <class name="Foo" entity-name="Foo_Audit" table="Foo_Audit"> > > <composite-id> > > <key-property name="Id" /> > > <key-property name="Revision" /> > > </composite-id> > > <property name="Data1" /> > > </class> > > > </hibernate-mapping> > > > When I query for just the Foo_Audit entites, NHibernate selects from > > Foo and Foo_Audit, returning Foo and Foo_Audit entities This happens > > with both criteria and HQL queries: > > > var results = session.CreateQuery("from Foo_Audit").List(); > > var results = session.CreateCriteria("Foo_Audit").List(); > > > This is not the behavior I expected. Is this the correct way to query > > for these entities? > > > Thanks, > > Jason > > > -- > > 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.
