customizing fetch type in hyperjaxb



I read this link about fetchtype in hyperjaxb. From the looks of it, it seems that one can only add a simpleType fetch-type to the xsd file and then add a fetch attribute to every complexType.


How would someone customize the following xsd fragment so that the resulting java method at bottom below would have a fetchtype=lazy annotation?



<xs:complexType name="SomeTypeName">
<xs:sequence>
<xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="someCode1" type="Code" minOccurs="0"/>
<xs:element name="someCode2" type="Code" minOccurs="0"/>
<xs:element name="someCode3" type="Code" minOccurs="0"/>
<xs:element name="someCode4" type="Code" minOccurs="0"/>
<xs:element name="someCode5" type="Code" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="Code">
<!--<xs:sequence>elements with nested data types omitted for simplicity</xs:sequence>-->
<xs:attribute name="code" type="xs:string" use="optional"></xs:attribute>
<xs:attribute name="Name" type="xs:string" use="optional"></xs:attribute>
</xs:complexType>


Here is the Java property that should say fetchtype=lazy:



@ManyToOne(targetEntity = Code.class, cascade = {
CascadeType.ALL
})
@JoinColumn(name = "SOME_CODE1_P_0")
public Code getSomeCode1() {
return someCode1;
}


Also, how specifically (i.e. with what specific syntax) does one set a global default for fetchtype in all methods, so that only some properties have to be overridden?


No comments:

Post a Comment