Customizing column names of @Embedded attributes in Hyperjaxb

155 views Asked by At

When using attributes with @Embedded the columns are named after a specific pattern which does not line up to my specific target database, thus I want to customize the generated name of the table.

In my specific use-case I cant change the schema and currently customize to my target database in my bindings.xjb.

I have an "item" of which I only want to persist the value:

<xs:complexType name="item">
    <xs:simpleContent>
        <xs:extension base="xs:string">
            <xs:attribute name="unwantedAttr1" type="xs:string"/>
            <xs:attribute name="unwantedAttr2" type="xs:string"/>
        </xs:extension>
    </xs:simpleContent>
</xs:complexType>

The item is used in "MyGroup" (and others) as the element-type.

<xs:element name="MyGroup">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="A01" type="item" />
        <xs:element name="A02" type="item" />
        <xs:element name="A03" type="item" />
      </xs:sequence>
    </xs:complexType>
</xs:element>

I would like to have the following resulting table:

HJID | A01 | A02 | A03

In my bindings.xjb I set item to be embedded and my unwanted attributes to @Transient:

<jaxb:bindings node="//xs:complexType[@name='item']">
    <hj:embeddable />
</jaxb:bindings>

<jaxb:bindings node="//xs:attribute[@name='unwantedAttr1']">
    <annox:annotate>
        <annox:annotate annox:class="javax.persistence.Transient"  />
    </annox:annotate>
</jaxb:bindings>

<jaxb:bindings node="//xs:attribute[@name='unwantedAttr2']">
    <annox:annotate>
        <annox:annotate annox:class="javax.persistence.Transient"  />
    </annox:annotate>
</jaxb:bindings>

I can change the column-name with

<jaxb:bindings node="xs:element[@name='MyGroup']//xs:element[@name='A01']">
    <hj:column name="A01" />
</jaxb:bindings>      

But this only gets me so far:

HJID | A01_VALUE | A02_VALUE | A03_VALUE

How can I implement such customizations?

I tried looking at the customizations guide and have the source code with tests at hand, but was unable to find anything related.

0

There are 0 answers