0

I'm working on a project to import a bunch of xml into a mysql database. I found the tool hyperjaxb3 that works as a maven plugin and generates jpa / jaxb annotated java classes that I can use to marshal xml and suck it in, but it creates its own primary key field. How do I get rid of that in favor of a field that exists in the schema?

specialK
  • 11
  • 2

1 Answers1

0

This is described in the documentation https://java.net/projects/hyperjaxb/sources/svn/content/trunk/www/doc/reference/en/pdf/reference.pdf

Particularly the section quoted below:

2.2.2.1. Customizing the identifier property Identifier property is customizable. Instead of generating a new idInternal property, you may force Hyper- JAXB to use an existing property as identifier. To do this, include @hyperjaxb.hibernate.id into the property javadoc annotation (from the simple test):

<xsd:complexType name="EntryType"> <xsd:sequence><!-- ... --></xsd:sequence> >
<xsd:attribute name="id" type="xsd:string"> <xsd:annotation> <xsd:appinfo>
<jaxb:property>     
<jaxb:javadoc> @hyperjaxb.hibernate.id unsaved-value="null" generator-class="uuid.hex"

</jaxb:javadoc>
</jaxb:property>
</xsd:appinfo>
</xsd:annotation> </xsd:attribute> </xsd:complexType>

If you use an id generator that needs to be parametrized, include the required parameters in @hyperjaxb.hibernate.generator-param.

user2643726
  • 461
  • 4
  • 2
  • Thanks for the answer! after I asked this, I found that I had to switch from hyperjaxb and parse the xml myself, due to a change in the project design – specialK Aug 12 '13 at 21:53