I want to override column names in by sub开发者_开发知识库class using xml. i know this can be done using @AttributeOverride JPA Anotations but want to achieve the same using XML Configuration ?
You can use the embedded and attribute-override elements.
See Chapter 3. Overriding metadata through XML/3.1.3. Property level metadata.
An example from this document:
<attributes>
<id name="id">
<column name="fld_id"/>
<generated-value generator="generator" strategy="SEQUENCE"/>
<temporal>DATE</temporal>
<sequence-generator name="generator" sequence-name="seq"/>
</id>
<version name="version"/>
<embedded name="embeddedObject">
<attribute-override name"subproperty">
<column name="my_column"/>
</attribute-override>
</embedded>
<basic name="status" optional="false">
<enumerated>STRING</enumerated>
</basic>
<basic name="serial" optional="true">
<column name="serialbytes"/>
<lob/>
</basic>
<basic name="terminusTime" fetch="LAZY">
<temporal>TIMESTAMP</temporal>
</basic>
</attributes>
精彩评论