How to map an XML data structure to a database with JPA (Java EE)

I am in a project where I receive XML data such as invoices from a service provider. These invoices have many items with the same structure, for example, Address, Type of service and amount of costs. I need to store this data in separate data sets in different rows. I received an XML schema file from my provider.

I could unmarshall xml files for java objects. Is there any way to insert this data into a database with JPA. the problem is that the generated JAXB classes that do not have annotations, such as Entity or columns, do not. I could annotate these classes, but after “clean and build” with Netbeans, the classes will be generated again without annotations.

Does anyone know a way to create classes from an XML schema with JAXB, read incoming XML files, unmarshal this? and write data to the database.

+5
source share
1 answer

You can use the Java Bean for the Java Bean, such as Dozer , to map the created classes to JPA objects.

0
source

All Articles