I learned what I needed about mappings from Hibernate in Action. Compared to the majority of books about frameworks, this is quite readable and thorough, and I enjoyed it. (I'm in no way related to the authors or the Hibernate team.)
If you download the Hibernate tools, you will find both command-line and graphical tools for generating. I prefer generating the other way round: from my Hibernate config files to DDLs and POJOs, because the Hibernate config files are easy enough, and they let you express everything you need. (If, e.g., generating Hibernate config files from the database structure, there is no way to find out about inheritance.) That way, you can be absolutely sure that the data types and mapping strategies of your cfg files, the attributes in your classes, and the data types in the database match.
I find generating a good way of reducing work and achieving consistency. However, it's not a good way to circumvent understanding the technology. As soon as the first error message appears, you will have to get familiar with cfg files anyway.
|