Can I load JPA mappings from Java annotations and save them as XML?

Is it possible to define JPA mappings with annotations only and then programmatically save the mapping data to some orm.xml file?

There is a discussion in the team about whether to use annotations or XML, and I want to check if we can start with annotations simply by going to a later point without manually overwriting all the XML files.

+4
source share
2 answers

There is a function request in the Eclipse Dali project ( bug 138622 ), but we do not support this. In the Juno release, we added support for converting global metadata (named queries, generators) from annotations to xml ( error 353149 ). As far as I know, there is no tool to convert all JPA annotation metadata to an orm.xml file.

+3
source

Not sure if there is a tool.

At run time, if you use EclipseLink, you can use XMLEntityMappingsWriter to write JPA metadata to XML. This is an internal API, but it works.

+1
source

Source: https://habr.com/ru/post/1442282/


All Articles