Hello
I am a newbie with Hibernate and I wanted to use the "composite-index" with xdoclet.
I have finally managed to use it although the "composite-index" tag is not mentionned by the xdoclet list :
http://xdoclet.sourceforge.net/xdoclet/ ... -tags.html
But as it is said there :
http://opensource.atlassian.com/project ... se/XDT-830
Xdoclet now supports this tag :
@hibernate.collection-composite-index
class="NameOfClass"
Here is my example :
I use a Map which contains customized "Preference" objects and the key is a "PreferencesKey" object with 2 properties : the string "language" and a integer "key_id" managed by myself (it is the simplest way I have found to have a list of "Preference" objets in my Map without using nested collections that are not supported by Hibernate).
Now, the xdoclet tags with "composite-index" are :
/**
* @hibernate.map
* table="XXXXXXXXX"
* lazy="true"
* cascade="all"
* @hibernate.collection-key
* column="my_object_id"
* @hibernate.collection-composite-index
* class="XXXXX.PreferencesKey"
* @hibernate.collection-many-to-many
* class="XXXXX.Preference"
* column="preference_id"
*/
I also have to describe the PreferencesKey class:
/**
* id manipulation
* @hibernate.property
* column="key_id"
*/
public int getId(){
return this.id;
}
public void setId(int id){
this.id = id;
}
/**
* langue manipulation
* @hibernate.property
* column="language"
*/
public String getLangue(){
return this.langue;
}
public void setLangue(String langue){
this.langue = langue;
}
And it works : xdoclet generates the right hbm.xml file :
[...]
<map
name="preferencesMap"
table="XXXXXXXXXX"
lazy="true"
sort="unsorted"
cascade="all">
<key column="my_object_id">
</key>
<composite-index
class="XXXX.PreferencesKey">
<key-property
name="id"
type="int"
column="key_id"/>
<key-property
name="langue"
type="java.lang.String"
column="language"/>
</composite-index>