-->
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: collection filter and polymorphism
PostPosted: Thu Jul 29, 2004 3:45 pm 
Beginner
Beginner

Joined: Thu Feb 26, 2004 11:32 am
Posts: 32
I am using hibernate-2.1 with joined-subclass mapping

I have a base class
EmployeeAttributes{
int attributesId
int dateId;
}
and 2 derived classes
EmpAttType1{
PensionAtt penAtt;
} and EmpAttType2.


Class Employee contains a collection of EmployeeAttributes (of type EmpAtt1 / EmpAtt2 ).

I am trying to use a collection filter to fetch attributes for a given dateId

session.createFilter(employee.getEmployeeAttributes(),"where this.dateId = " + dateId ); works fine

but I am not sure how to typecast in this query so that I can retrieve
pensionAtt for a given dateId

I am trying to do something like :

PensionAtt currentPenAtt = session.createFilter(employee.getEmployeeAttributes(),"select this.pensionAtt where this.dateId = " + dateId );

which doesnt work because object returned by collection is of type 'EmployeeAttribute' and not of 'EmpAttType1'


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.