• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xdoclet and hibernate

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you used xdoclet along with hibernate?
i have heard that xdoclet has a nice collection of hibernate tags
which generate class to database mapping for POJOs.
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michal Szklanowski:
have you used xdoclet along with hibernate?
i have heard that xdoclet has a nice collection of hibernate tags
which generate class to database mapping for POJOs.


While I haven't personally used Hibernate yet, one of the developers of XDoclet has been using them together for some time and swears by it. You can post to the xdoclet-user mailing list and most likely Konstantin will chime in.
 
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed. XDoclet does come with a Hibernate module that generates XML mapping files for POJOs. You can also generate a session factory class that loads all of the Hibernate XML files and manages your Hibernate sessions. There's also a subtask of <hibernatedoclet> that generates JBossMX MBean descriptors for Hibernated classes (but to be honest, I've not monkeyed with this subtask much).
The <hibernate> subtask generates one *.hbm.xml mapping file per hibernated class. Much of the work on this subtask was done by Gavin King (Hibernate's creator), so you know it's good stuff. The biggest issue with the Hibernate module is that the online documentation is out-of-date. One of the last things I did during production of the book was to review the reference appendices and update them. The Hibernate module had changed dramatically, so I had lots to do. The good news is that the reference appendices will contain the most up-to-date Hibernatedoclet material anywhere.
Aside from the examples in the book, we've employed the <hibernatedoclet> task on two projects at my day job and have had much success. I'm also working on a side project off-and-on and am just now starting to tag everything for Hibernate mapping generation. So far, so good. The biggest hangup I have is that I'm not quite the Hibernate expert I'd like to be, especially with regard to relationships. So it takes me awhile to sort things out.
The one thing that turns many people off of using XDoclet to generate Hibernate mapping files is that there's really not much of a time-savings. You end up tagging your POJOs quite a bit and the trade-off between tagging and writing the mapping files by hand isn't that great. But saving time and work isn't the only thing XDoclet buys you. Tagging your classes for Hibernate mapping is much better than writing the mappings by hand because each tagged class is the authoritative, unambiguous definition of the class. If you wrote the mappings by hand, each class' definition is spread out across two files. In fact, I argue that tagging a class for Hibernate mapping generation makes more sense than tagging an EJB for deployment descriptor generation.
reply
    Bookmark Topic Watch Topic
  • New Topic