3

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

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
Granted, but once you've got annotations, why would you want the mapping files?
1

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.

Comments

1

The way I get around this short coming is to use 1) Grails to generate the pojos. Any scaffolding framework would suffice. 2) Then Eclipse to reverse engineer the database tables into pojos.

Works everytime.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.