-->
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: different sets for subclasses of same base class
PostPosted: Tue Jul 10, 2007 3:25 pm 
Newbie

Joined: Tue Jul 10, 2007 3:12 pm
Posts: 1
Hi

I am looking for solution for following problem:
I have a class User which has two collections (Comments and ProperContentItems). Comment and ProperContentItem are subclasses of abstract class ContentItem. All of them are persistable. Mapping strategy is table-per-hierarchy with discriminator called "CONTENT_TYPE".
I am using XDoclets, and definitions concerned are as follows:

...
/**
* @hibernate.set
* inverse="true"
* lazy="true"
* cascade="all"
* where="CONTENT_TYPE='COMMENT'"
* @hibernate.collection-key
* column="OWNER_ID"
* @hibernate.collection-one-to-many
* class="hibernate.Comment"
*/
public Set<Comment> getComments() {
return comments;
}
...
/**
* @hibernate.set
* inverse="true"
* lazy="true"
* where="CONTENT_TYPE='PROPER_CONTENT_ITEM'"
* cascade="all"
* @hibernate.collection-key
* column="OWNER_ID"
* @hibernate.collection-one-to-many
* class="hibernate.ProperContentItem"
*/
public Set<ProperContentItem> getProperContentItems() {
return properContentItems;
}
...

As you can see I am using 'where' tag, which in my opinion is unnecessary (I mean Hibernate can figure out what value should have 'CONTENT_TYPE' column - according to 'class' tag).
And now there is my question: is there some way to avoid this overexplicity (I mean more elegant way of achieving same solution)?

I hope the above is understandable :)

P.S. I am using Hibernate ver. 3.0 (the one shipped whit JBoss 4.0.5).

Thanks in advance and best regards,
Kamil


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.