如何使用xml配置而不是JPA Anotations @AttributeOverride列名称 [英] How to @AttributeOverride of column names using xml configuration instead of JPA Anotations

查看:111
本文介绍了如何使用xml配置而不是JPA Anotations @AttributeOverride列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过使用xml的子类来覆盖列名。
i知道这可以使用@AttributeOverride JPA Anotations来完成,但是希望使用XML Configuration来实现相同的功能吗?

可以使用嵌入式和属性覆盖元素。



请参阅第3章通过XML / 3.1.3覆盖元数据属性级别元数据



本文档中的示例:

 <属性> 
< id name =id>
< column name =fld_id/>
<生成值生成器=生成器strategy =SEQUENCE/>
< temporal> DATE< / temporal>
< / id>
< version name =version/>
< embedded name =embeddedObject>
<属性覆盖名称subproperty>
< column name =my_column/>
< / attribute-override>
< / embedded>
< basic name =statusoptional =false>
<枚举> STRING< /枚举>
< / basic>
< basic name =serialoptional =true>
< column name =serialbytes/>
< lob />
< / basic>
< basic name =terminusTimefetch =LAZY>
< temporal> TIMESTAMP< / temporal>
< / basic>
< / attributes>


I want to override column names in by subclass 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>

这篇关于如何使用xml配置而不是JPA Anotations @AttributeOverride列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆