Wednesday, December 14, 2005

Hibernate Annotations

Just finished porting a project that used XDoclet to Hibernate Annotations. It was very simple and besides for two small problems, it worked pretty well. XDoclet didn't work as I wanted and I had already started changing the Hibernate mapping files directly. Now, it is much cleaner, sort of ready for EJB 3.0, and I don't have to generate mapping files (or change them manually).

One of the problems was that EJB 3.0 specification don't use the class qualified name, so you have an exception when you have two classes with the same name. I had to explicitly set the qualified names.

The other problem was that the cascade types for persistence in EJB specification is not as extense as Hibernate ones. I wanted a save and update operations cascade, but couldn't find this option, then I set the persist cascade type, but it didn't work. So, I had to use a hibernate specific annotation (@Cascade(value=CascadeTypes.SAVE_UPDATE)). Anyway, now everything is working fine.
Post a Comment