【问题标题】:How to annotate a generated property as Transient in HyperJaxb3如何在 HyperJaxb3 中将生成的属性注释为瞬态
【发布时间】:2018-04-02 14:57:11
【问题描述】:

我只想拥有一个实体的属性作为瞬态。 HyperJaxb 的旧文档[1] 似乎不可用,Github 上的文档[2] 对我没有帮助。

我尝试使用可嵌入/可嵌入属性和生成的 id 构造,但没有成功。

我有一个模型如下,我想在生成的类中将 lastActivityTime 作为瞬态。该字段的当前注释是我的一次失败的尝试。

<xsd:complexType name="ProcessInstanceGroupDAO">
    <xsd:sequence>
        <xsd:element name="Name" type="xsd:string"/>
        <xsd:element name="archived" type="xsd:boolean"/>
        <xsd:element name="lastActivityTime">
            <xsd:annotation>
                <xsd:appinfo>
                    <hj:persistence>
                        <hj:embeddable merge="false">
                            <orm:embeddable-attributes>
                                <orm:transient name="lastActivityTime"></orm:transient>
                            </orm:embeddable-attributes>
                        </hj:embeddable>
                    </hj:persistence>
                </xsd:appinfo>
            </xsd:annotation>
        </xsd:element>
    </xsd:sequence>
</xsd:complexType>

[1] confluence.highsource.org/display/HJ3/Customization+Guide

[2] https://github.com/highsource/hyperjaxb3/wiki/Customization_Guide

【问题讨论】:

    标签: java orm transient hyperjaxb


    【解决方案1】:

    只需使用&lt;hj:ignored/&gt; 对其进行注释。该属性将被注释为@Transient

    <xsd:complexType name="ProcessInstanceGroupDAO">
        <xsd:sequence>
            <xsd:element name="Name" type="xsd:string"/>
            <xsd:element name="archived" type="xsd:boolean"/>
            <xsd:element name="lastActivityTime">
                <xsd:annotation>
                    <xsd:appinfo>
                        <hj:ignored/>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    

    免责声明:我是 Hyperjaxb 的作者。不幸的是,我不再积极开发它。

    【讨论】:

    • 太好了,非常感谢@lexicore!关于旧文档。与 Github 中的相比,我不知道它的覆盖范围更大。如果是这样,是否可以在短时间内在线提供,以便我可以下载它?
    • 请参阅:github.com/highsource/hyperjaxb3/issues/37 我认为 wiki 包含所有旧文档,使用一些转换器从旧 Confluence 转换而来。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-15
    • 2019-03-24
    • 1970-01-01
    • 2016-12-15
    • 2020-03-26
    • 2014-11-01
    • 1970-01-01
    相关资源
    最近更新 更多