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
|