-->
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: Subclass Attribute Search - BUG or FEATURE of Hibernate ...
PostPosted: Sun Jul 15, 2012 3:34 pm 
Newbie

Joined: Sun Jul 15, 2012 3:26 pm
Posts: 1
The case involves both inheritance and association mappings

Class Structure is as under:
abstract Class ContactDetail
{
String type;
String label;
Long id;
}

Class Email extends ContactDetail
{
// discriminator value type is set to 'E'
String emailAddress;
}

Class PhoneNumber extends ContactDetail
{
// discriminator value type is set to 'P'
String phoneNumber;
}

Class PostalAddress extends ContactDetail
{
// discriminator value type is set to 'A'
String addressLine1;
String addressLine2;
String addressLine3;
String city;
String state;
String country;
String zip;
}

I hv these mapped based on the Table per Class Hierarchy model and it works fine.

Next Step was to add these as a collection to a Person Class.

Class Person
{
Long id;
Collection<ContactDetail> contactDetails;
}

I need this collection based on a JoinTable and hv used required mappings and am able to do fetch etc.

The problem comes when I want to query for a Person based on phoneNumber / EmailAddress.

Query q1 = session.createQuery("select e from Person as e, IN (e.contactDetails) as c WHERE c.emailAddress like :p1");
Query q2 = session.createQuery("select e from Person as e, IN (e.contactDetails) as c WHERE c.phoneNumber like :p2");

etc. work - "querying on subclass attributes ..."

But is it a BUG or a FEATURE of hibernate ?? Can I rely on this feature existing in future versions of Hibernate ??


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.