tags:

views:

958

answers:

3

What's the best/easiest way to generate *.hbm.xml files from pojos?

A: 

Pojo's don't have an inherent ORM mapping. Mapping files (or mapping annotations) are the 'value added' of hibernate. If you really wanted to try something like this you could annotate all your classes with @Entity and try to get hibernate to generate schema based on this.

Jherico
Thanks, @Jherico. I realize now that it seems possible to reverse engineer a database schema into pojos, but not really possible to reverse engineer pojos into database schema from xml. It is possible, however, to annotate classes (like you suggested), generate schema, then reverse engineer the schema to get the xml.
Dave Paroulek
Granted, but once you've got annotations, why would you want the mapping files?
Jherico
A: 

You can use xdoclet to do this. Or you can use Hibernate's JPA implementation (Hibernate Annotations), add annotations to your POJOs, and get rid of the .hbm.xmls once and for all.

Kaleb Brasee
A: 

Is there any way or any utility to generate hibernate mapping files or directly the database tables from POJOs. I cannot manually insert hibernate annotations since these POJOs are generated dynamically in my application. Please suggest a solution.

Deep