Well, my solution is:
Code:
<map name="relatedContents" cascade="all">
<key column="keyRelContent"/>
<!-- the index will be DRAFT or PUBLISHED -->
<index column="publisherStatusIndexVersContent" type="java.lang.Integer"/>
<one-to-many class="com.zz.contentManagement.model.Content"/>
</map>
Then, into the VersionedContent Objet i have...
Code:
public Content getPublishedContent() {
if (this.getRelatedContents() == null
|| this.getRelatedContents().isEmpty()) {
com.zzz.util.log.LogUtil.getDebugLogger().warn(
"Inconsistent model, there is no map assigned for versioned content id = "
+ this.getId());
return null;
} else {
return (Content) this.getRelatedContents().get(
VersionedContent.RELATED_CONTENT_INDEX_PUBLISHED);
}
}
public void setPublishedContent(Content content) {
if (this.getRelatedContents() == null) {
com.oneplanettravel.util.log.LogUtil.getDebugLogger().warn(
"creating content map for VersionedContent = " + this.getId());
this.setRelatedContents(new HashMap());
}
this.getRelatedContents().put(
VersionedContent.RELATED_CONTENT_INDEX_PUBLISHED,
content);
}
public Content getDraftContent() {
if (this.getRelatedContents() == null
|| this.getRelatedContents().isEmpty()) {
com.zzz.util.log.LogUtil.getDebugLogger().warn(
"Inconsistent model, there is no map assigned for versioned content id = "
+ this.getId());
return null;
} else {
return (Content) this.getRelatedContents().get(
VersionedContent.RELATED_CONTENT_INDEX_DRAFT);
}
}
public void setDraftContent(Content content) {
if (this.getRelatedContents() == null) {
com.zzz.util.log.LogUtil.getDebugLogger().warn(
"creating content map for VersionedContent = " + this.getId());
this.setRelatedContents(new HashMap());
}
this.getRelatedContents().put(
VersionedContent.RELATED_CONTENT_INDEX_DRAFT,
content);
}
This is not so clean, but leaves the door open to a more complex version system (now there is only a 'one level' deep).
Thanks