How to create a customised primary key in hyperjaxb3?

387 Views Asked by At

Currently I'm using hyperjaxb3 to generate java classes from XSD which i use for DB schema. every time i generate java classes it creates a variable called HJID and this HJID is considered as primary key by default. i don't want to use this HJID as primary key as i want to create my own primary key.

can any one let me know the changes i need to do in my XSD to override the HJID ?

1

There are 1 best solutions below

0
On

You can mark an existing field as ID, if this is what you want.

http://confluence.highsource.org/display/HJ3/Customization+Guide#CustomizationGuide-Selectingtheidentifierproperty

<xs:complexType name="myType">
    <xs:sequence>
        <!-- ... -->
        <xs:element name="id" type="xs:int" minOccurs="0">
            <xs:annotation>
                <xs:appinfo>
                    <hj:id>
                        <orm:column name="MY_ID"/>
                        <orm:generated-value strategy="SEQUENCE" generator="my-sequence"/>
                        <orm:sequence-generator name="my-sequence" sequence-name="MY_SEQ"/>
                    </hj:id> 
                </xs:appinfo>
            </xs:annotation>
        </xs:element>
        <!-- ... -->
    </xs:sequence>
</xs:complexType>

Disclaimer: I'm the author.