[英]customizing hibernate properties in hyperjaxb
hyperjaxb
的默認配置是創建休眠注釋,該注釋將導致hibernate
注釋生成令人難以置信的冗長的SQL
語句,從而使SQLException
的性能最差,並且性能最佳。 具體來說, CascadeType.ALL
設置似乎是默認設置。 如何覆蓋默認設置,以便在自定義基礎上設置CascadeType
, FetchType
和其他參數? 是否可以在全局級別上設置這些默認變量,以使我不必更改schema.xsd文件中數百個引用中的每個引用?
這是一個例子。 Hyperjaxb
正在生成以下hibernate
注釋:
@ManyToOne(targetEntity = Code.class, cascade = {
CascadeType.ALL
})
@JoinColumn(name = "SOME_CODE1_P_0")
public Code getSomeCode1() {
return someCode1;
}
來自以下架構片段:
<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>
您可以根據需要自定義默認映射:
http://confluence.highsource.org/display/HJ3/Customizing+default+mappings
這是默認的自定義 。
這是一個自定義默認值的測試項目。
例如,為many-to-one
自定義默認級聯看起來像(未經測試):
<jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema">
<hj:persistence>
<hj:default-many-to-one>
<!-- So what do you think to be a reasonable default mapping? -->
<orm:cascade>
<orm:cascade-persist/>
</orm:cascade>
</hj:default-many-to-one>
</hj:persistence>
</jaxb:bindings>
更多鏈接:
請檢查文檔。 您可以(但不必)自定義很多 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.