HyperJAXB3 Per type customizations - highsource/jaxb-tools GitHub Wiki
Previous sections explained how you can customize mapping generated for a certain property. A further feature of Hyperjaxb3 is the ability to customize all properties of the certain type (I mean an XML Schema type here) with one shot. This allows you to express things like "all strings must be mapped to columns of length 1000" or "properties of xs:hexBinary
are mapped as LOBs".
Since single and collection properties of the same type have different mappings, per-type customizations are distinguished by cardinality. You will typically use hj:default-single-property
element for single properties and hj:default-collection-property
element for collection properties.
In order to customize certain type, define hj:default-single-property
sub-element of hj:persistence
:
<hj:persistence>
<hj:default-single-property type="tns:mySimpleType">
<hj:basic>
<orm:column scale="2" precision="1"/>
<hj:enumerated-value/>
</hj:basic>
</hj:default-single-property>
</hj:persistence>
You can even override the mappings for built-in types, for instance change the precision of xsd:double
mapping (default is 10/20):
<hj:default-single-property type="xsd:double">
<hj:basic>
<orm:column scale="5" precision="10"/>
</hj:basic>
</hj:default-single-property>
See the following project for example:
At the moment works only with simple types.