简体   繁体   中英

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

I'm on a project, where I get XML data like invoices from a service provider. These invoices have many positions with the same structure, like Adress, Service Type, and amount of costs. I need to store this data in seperate datasets in different rows. I got an XML schema file from my provider.

I could unmarshall the XML files to java Objects. Is there a way to insert this data to a database with JPA. the problem is, that the through JAXB generated classes doesn't have annotations like Entity or columns. I could annotate these classes but after a "clean and build" with Netbeans the classes will be generated again without annotations.

Anyone know a way to build classes from XML schema with JAXB, read the incoming XML files, unmarshal this? and write the data to database.

您可以使用Java Bean到Java Bean映射器(如Dozer)将生成的类映射到JPA实体。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM