Search code examples
javaormtransienthyperjaxb

How to annotate a generated property as Transient in HyperJaxb3


I just want to have a property of an Entity as Transient. The older documentation[1] of HyperJaxb seems unavailable and the one on Github[2]did not help me.

I tried to use embeddable/embeddable attributes and generated-id constructs with no success.

I have a model as follows and I want to have lastActivityTime as Transient in the generated class. The current annotation of this field is one my unsuccessful attempts.

<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


Solution

  • Simply annotate it with <hj:ignored/>. The property will be annotated with @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>
    

    Disclaimer: I am the author of Hyperjaxb. Unfortunately I no longer actively develop it.