-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Find a classes discriminator value
PostPosted: Tue Aug 03, 2004 5:47 pm 
Beginner
Beginner

Joined: Tue Sep 09, 2003 9:11 pm
Posts: 32
I'm trying to programitically figure out the discriminator value if I have a class. Is there a recommended way to find the value? There doesn't seem to be a method on ClassMetadata like discriminatorValue().

For a generic reporting funtion, I'm trying to create a criteria that restricts itself to a sub-class of records for a joined property. For example:
Code:
public List void findRecords(Class restrictToClass){
   Criteria c = session.createCriteria(Primary.class);

   Criteria cProperty = c.createCritiera("joinProperty");
   cProperty.add(Expression.eq("class", restrictToClass));

   return c.list();
}


However, the discriminator value must be used and not the class name.

If it doesn't exist, I'm looking to write the translation method (class->value). I started down the path of subclassing EqExpression and changing getTypeValue (to do the translation since it has access to PresistorClass where the value is available) and I was wondering if there is a better way to accomplish this.

I can always hard code the discriminator value; however, I'm trying to make the code easier to read and maintain.....

Chris....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.