What's the best/easiest way to generate *.hbm.xml files from pojos?
3 Answers
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.
2 Comments
Upgradingdave
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.
Tano
Granted, but once you've got annotations, why would you want the mapping files?
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.