When you use <any> you must use explicit join.As restriction you can use two
special properties:
yourEntity.Person.class
yourEntity.Person.id

Person.class is the string with the entity name or the MetaData you have
used in the mapping
Person.id is the ID

I'm not sure about its usage for CriteriaAPI but sure it work for HQL.

2009/2/4 ilmatte <m.tont...@gmail.com>

>
> Hello,
>
> I've got a class, say Person, with a property of type IHouse and I've
> got several implementations of IHouse (Building, Tent, Manor, Castle,
> etc).
> I mapped the property with the tabel-per-concrete-class strategy,
> relying on implicit polymorphism.
>
> This means having something like this in my Person.hbm.xml mapping
> file:
>
> <any name="Person"
>         cascade="all"
>         meta-type="class"
>         id-type="System.Int32">
>      <column name="house_class"/>
>      <column name="house_id"/>
> </any>
>
> Now I'm trying to implement a method in my repository to retrieve all
> the instances of Person with a specified value for a property of the
> IHouse instance associated:
>
> GetAllPersons(int roomsNumber)
> {
>            using (ISession session = NHSessionManager.GetSession())
>            {
>                ICriteria criteria = session.CreateCriteria(typeof
> (Person)).
>                    CreateCriteria("House").
>                    Add(Expression.Eq("RoomsNumber", roomsNumber));
>                return criteria.List<Person>();
>            }
> }
>
> This method doesn't work stating that: 'any types do not have a unique
> referenced persister'.
>
> I guess that this is what the documentation means when stating that
> polymorphic joins are not supported for table-per-concrete-class
> (implicit polymorphism) inheritance strategy (see table 8.1 at page
> 68).
> Is it true? Is there no way to query Person instances based on a
> property of IHouse using implicit polymorphism? Maybe HQL or anything
> else?
>
> Hope that someone can help me.
>
> Thank you,
>
> Matteo Tontini
>
> >
>


-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to