0

HyperJAXB generates @ManyToOne Annotations for XSD 1:1-relationships like:

<xs:element name="typeName" type="otherType" />

or

<xs:element name="typeName" type="otherType" minOccurs="0" maxOccurs="1" />

This is not the expected behaviour since it should generate @OneToOne Annotations. Well, the customization guide describes that you can customize this behaviour by adding instructions to every single element definition (see http://confluence.highsource.org/display/HJ3/Making+schema-derived+classes+ready+for+JPA, paragraph "Mapping as one-to-one").

This is fine, but I need a global configuration for this. Can anybody please tell me, what to put in bindings.xjb to achieve this goal?

Martin Dames
  • 264
  • 3
  • 13

1 Answers1

1

You can switch X:1 by default to one-to-one globaly:

<jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema">
    <hj:persistence>
        <hj:default-to-one>
            <hj:one-to-one/>
        </hj:default-to-one>
    </hj:persistence>
</jaxb:bindings>

However be warned, I think I've opted to @ManyToOne by default for a reason. It was safer and easier to handle.

lexicore
  • 42,748
  • 17
  • 132
  • 221
  • Hi, what is the schema for hj namespace? I am asking because I would like to add these binding settings directly into XSD schema itself. – kensai Aug 29 '17 at 10:52
  • @kensai https://github.com/highsource/hyperjaxb3/tree/master/ejb/schemas/customizations/src/main/resources – lexicore Aug 29 '17 at 11:26
  • thx a lot! either I understand the project is not in active dev, it is really superior for those who model in XSD first, as me for middleware... – kensai Aug 29 '17 at 11:33