20030213 Thursday February 13, 2003

XDoclet for Hibernate A nice community-enhancing developer (I don't know who) has posted an XDoclet for Hibernate tutorial on Hibernate's Wiki. Good stuff. Since the XDoclet doco is kinda cryptic, it'd be awesome if someone did this for Struts. Maybe in my spare time. Oh wait, I have none of that - at least not this week.

I think XDoclet and Hibernate work well together when creating a database schema from scratch. However, I've found that Hibernate's Reverse Engineering Tool works much better for me. It generates the .java and .hbm.xml files for me and I'm done. Hook up a DAO and a DAOTest and I'm done! I might look at Middlegen's recently added Hibernate support in my next class-generation cycle. To my knowledge, it creates an XDoclet-enabled .java file that can then generate the .hbm.xml. However, I'm using a lot of composite-id stuff and XDoclet doesn't seem to support that. From the above XDoclet for Hibernate article:

Note that XDoclet will not be able to support the new composite features.

Posted in Java at Feb 13 2003, 05:22:44 AM MST 1 Comment

Comments:

Thanks for the friendly title. I wrote the article specifically because there is very little "walk-through" documentation for XDoclet, let alone specifics to Hibernate. XDoclet is 95% effort to setup, and 5% effort to use. I agree that if your tables already exists the reverse engineering tool to be quite useful. For me, however, this isn't really too useful as I tend to strongly separate my Hibernate implementations from the business objects beans. I guess out of paranoia that for some reason I find something better than Hibernate. I tie my business objects to the Hibernate clode either by interface implementation or inheritence. I also tend to duplicate my getter and setter methods by providing specific methods for Hibernate to use on the implementation. For example get/setName on the bean now has a get/setHbmName on the Hibernate implementation. Sure it's more work, but I can know hook update calls into the setName method and I have an almost transparent, persistable business object. I was thinking of writing up another tutorial based on this design idea. I would be interested in bulletproofing the idea and identifing flaws that I'm sure are there.

Posted by Martin on February 21, 2003 at 02:08 PM MST #

Post a Comment:
  • HTML Syntax: Allowed
Click me to subscribe
Matt Raible is the Lead UI Architect at LinkedIn. The opinions on this site are mine, not my employers.
« November 2008
SunMonTueWedThuFriSat
      
1
2
3
6
7
8
9
10
11
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
      
Today

Recent Entries

Tag Cloud