Getting Started

I have been hacking Hibernate to figure out how to make this Object Relational Mapping to work. The idea of Hibernate is great, but the details of using it seem to be dispersed and confusing. The original technique uses the hbm.xml file that maps a class to fields in the database. Perform your crud operations on your object and it automatically gets persisted to your database. The new technique uses annotations. Drop annotations in your code and it will tell Hibernate how to persist the object, no separate hbm.xml file required. But, at one time, the Hibernate developers created Hibernate Tools that contained a tool that would generate your classes from the hbm.xml file as well as the Data Definition Language for the database. These were originally built for Ant, but now most of Hibernate has switched to Maven, which its self seems to have its own learning curve and complexities. The bonus side is that it will automatically use the Maven repository. Thus, I am curious how to make the Hibernate Tools work with Maven, the same way they work in the Harnessing Hibernate book by James Elliot et al. The great thing is that the from the hbm.xml file, one can generate .java files using hbm2java and the database definitions using hbm2ddl. I find this way very interesting, as the hbm.xml already describes the .java and the data definition. The trick is making them work in Maven.

About Brian Lavender

I like to program in C++, Java, and Pascal. I have an admiration for languages like Pascal, Ada, and Eiffel. I work a lot with GNU/Linux systems.
This entry was posted in Hibernate. Bookmark the permalink.