NetBeans and Hibernate Tools

Been test-driving more server-side packages. After playing around with NBXDoclet and JBoss-IDE I’ve decided to use Hibernate Annotations and the plug Hibernate Tools into NetBeans using the Ant Tasks.

NBXDoclet

I first tried out NBXDoclet, a NetBeans plugin that provides support for XDoclet and Hibernate (and a lot of stuff). It provides a lot menu options and special dialogs for creating properties, getters, setters, and the XDoclet markup to make “Hibernatable” POJOs. Ran into some bugs when trying to create an association. There is not much in the way of documentation, but the Flash demo gives you most of what you need. This project shows promise, but face it, XDoclet is not the wave of the future.

JBoss-IDE

JBoss-IDE is a set of plugins for Eclipse. After using NBXDoclet, I had high expectations for JBoss-IDE. I was let down. I found the whole thing rather confusing and under-featured. This is partly because I don’t want to reverse-engineer a database. I’d much rather take my code and a database driver and generate the schema.

I had used Hibernates Ant Tools on previous projects (many versions ago) and the “IDE” didn’t really seem to offer much beyond features of the ant tools.

Hibernate Annotations and Ant Tools

So, I went back to NetBeans and tried the new jdk1.5 annotations. This is the way to go, you can use which ever IDE you want (as long as it supports annotations) and get code completion for the annotations without waiting for someone to build/debug/update dialogs.

Integrating the the Hibernate Ant Tools into NetBeans is relatively easy. I created a seperate ant file for the hibernate stuff. Created a library in NetBeans Library Manager to house the Hibernate Tools jar files. Imported the NBUser properties into my new ant file and used the classpath setup for hibernate tools. Tested the whole thing from the command-line to get it working. Then I changed to target name to “-post-compile” and included my new ant script in the projects ant script (include it BEFORE the build-impl.xml file). So now when I compile, it creates a new schema and documentation. I even tried generating a Seam application.

The sticky part is a small bug. One of the jars included in the hibernate tools is the wrong version. And to get the seam application to deploy, you need to use a nightly-build of the hibernate tools. And be sure everything (Ant and JBoss) are running under Java 5.

Once the EJB3.0 and J2EE1.5 parts of JBoss become more stable, it would be rather easy to wrapper the libraries and provide a few file templates to create a full-blown JBoss/EJB3 NetBeans plugin.