Target-per-entity hierarchy problem

Posts   
 
    
apenic
User
Posts: 7
Joined: 28-Nov-2005
# Posted on: 30-Jan-2006 13:50:59   

Hi!

I'm using Target-per-entity hierarchy type. For example, the supertype is submission and there are two types of submission entity, Registration and Modification with its subordinate entities. Submission entity has RegistryNumber property which is unique on persistency level. Submission with specified registry number can be either Registration or Modification type. Each of them has it's own PrefetchPath elements I want to use. If I have information about registry number only (don't know which subtype is requested), and I would like to be able to fetch appropriate entity (with it's subordinate entities) for specified RegistryNumber.

What's the best practice for this kind of fetch?

Thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-Jan-2006 14:47:48   

Please refer to the following thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5080

Come back to us if this doesn't help you.

Good Luck

apenic
User
Posts: 7
Joined: 28-Nov-2005
# Posted on: 30-Jan-2006 15:16:56   

The given thread (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5080) explains how to create PrefetchPath elements for subtypes. I'm OK with that.

To translate my problem to given example, I am trying to fetch Employee or any of it's subtypes in single fetch. So, if I use EmployeeEntityFactory and get EmployeeEntity, how could I find out if it is any of Employee subtypes?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 31-Jan-2006 02:22:07   

The FetchNewEntity method is polymorphic, so if you do something like // C# RelationPredicateBucket filter = new RelationPredicateBucket(); filter.PredicateExpression.Add(SubmissionFields.RegistryNumber == 1); SubmissionEntity submission = adapter.FetchNewEntity(new SubmitionEntityFactory(), filter);

now your submission entity should be of the correct subtype.

apenic
User
Posts: 7
Joined: 28-Nov-2005
# Posted on: 31-Jan-2006 10:19:52   

Thanks. It works.