【问题标题】:Is custom entity mapping able to configure parent attributes?自定义实体映射是否能够配置父属性?
【发布时间】:2013-03-04 15:59:50
【问题描述】:

我正在开发一个提供生成模型的框架。该模型从该框架扩展了一个类。

// Framework
Class Parent {
 private short version;
}

// Generated
Class Child extends Parent {
 private <type> attribute;
}

我想允许用户激活提供自定义实体映射的乐观锁定。 custom-orm-psql.xml 通过 persistence.xml 链接。

<entity class="package.Child" metadata-complete="false">
    <attributes>
        <version name="version" />
    </attributes>
</entity>

我能否因为无法激活乐观锁定而更改父属性映射? 它与属性version 上的@Version 注释一起使用。

【问题讨论】:

    标签: hibernate jakarta-ee orm persistence


    【解决方案1】:

    是的,您可以更改映射的父类定义。确保 Parent 类上面有注释 @MappedSuperclass 。那么子类可以继承父类的所有映射信息。

    【讨论】:

    • 我的父类是@MappedSuperclass,但它不起作用,版本永远不会更新...
    猜你喜欢
    • 1970-01-01
    • 2014-08-08
    • 2013-09-14
    • 2012-05-25
    • 1970-01-01
    • 1970-01-01
    • 2014-11-19
    • 2015-06-09
    • 1970-01-01
    相关资源
    最近更新 更多