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.

Reply via email to