我正在使用hyperjaxb从XSD文件生成JAXB-JPA注释类。我有很多遭遇的Persona实体。这是自定义部分
<bindings node="xsd:complexType[@name='PersonaType']">
<bindings node=".//xsd:element[@name='id']">
<hj:id>
<orm:generated-value strategy="AUTO"/>
</hj:id>
</bindings>
<bindings node=".//xsd:element[@name='encounters']">
<hj:one-to-many name="encountersRel">
<orm:join-table name="PERSONA_ENCOUNTER">
<orm:join-column name="PERSONA_ID"/>
<orm:inverse-join-column name="ENCOUNTER_ID"/>
</orm:join-table>
</hj:one-to-many>
</bindings>
</bindings>
到目前为止一切顺利。问题是,默认情况下,这会生成此映射
/**
* Gets the value of the encounters property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the encounters property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getEncounters().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link EncounterType }
*
*
*/
@OneToMany(targetEntity = EncounterType.class, cascade = {
CascadeType.ALL
})
@JoinTable(name = "PERSONA_ENCOUNTER", joinColumns = {
@JoinColumn(name = "PERSONA_ID")
}, inverseJoinColumns = {
@JoinColumn(name = "ENCOUNTER_ID")
})
public List<EncounterType> getEncounters() {
if (encounters == null) {
encounters = new ArrayList<EncounterType>();
}
return this.encounters;
}
/**
*
*
*/
public void setEncounters(List<EncounterType> encounters) {
this.encounters = encounters;
}
问题是我需要映射使用Set
而不是List
。如何使用自定义实现此目的?