NetBeans and Hibernate Tools

Mar 8, 10:45 PM

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.

Comment


Thank you for feedback and comparing with others tools. You are right xdoclet is not future. BTW xdoclet\'s model is equivalent with java annotations. Convert from xdoclet to annotations is something like XSLT in xml. Only someone have to write converter (with Jackpot it should be simple.) .

The bugs with associations has been fixed. I will have to release another build. I would like to add annotations to nbxdoclet. It\'s no so difficult (to rewrite templates in velocity language and to extend xdoclet model to be able read and generate annotations) . But I don\'t have time now to do it:(.

Petr Zajac · Mar 13, 08:35 AM · #

Hi Adam!
It\'s good to see you are doing well. Drop me an email I would love to catch up on what you have been doing.

Tommy Vinson
Alpharetta, GA

— Tommy Vinson · Apr 28, 06:16 PM · #

Better late than never ;)

\"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.\"

No part of the code generation *requires* reverse engineering.
Reverse engineering is an *option*.

\"the “IDE” didn’t really seem to offer much beyond features of the ant tools.\"

Would you rather that I added good features that were only accessible via eclipse ? :)

In any case here the features that is not Ant/build related:

HQL Query editor
Criterya editor
Dynamic SQL Preivew
Query execution and result introspection
Inline HQL code validation
Mapping Visualization
FreeMarker editor
...and more ;)

But somehow we must have hidden those features from you ;)

— max · Jun 5, 03:18 PM · #

max, No need to get snotty. As I said, I had high expectations -- higher than what I saw and higher than your list of features I didn\'t see. One of my complains against Eclipse and IDEs in general is that the features of plugins are often in non-obvious places. I like being able to use the most important features from ant -- In fact I PREFER ant to Eclipse. I would prefer to download the hibernate tools separately from the eclipse plugin.

Adam · Jun 5, 05:06 PM · #

I don\'t think max was being snotty. And your blog hasn\'t left me with the impression that you are 100% up on all this tech.

I do agree with the notion that plugins end up providing features in all sorts of weird places - I\'d prefer to have barebones access to everything, and a decent 5 minute ramp up (where to stick everything, and what to stick in it). Then I can float around by myself, with enough jargon absorbed to harness the google.

— Wilkes · Mar 25, 05:09 PM · #

@Wilkes
If by not \"100% up on all this tech\" you mean that I don\'t know eclipse well enough too find the features added by plugins in less time than it would take for me create ant tasks, then I\'ll agree. I don\'t use eclipse enough to really be familiar with anything other than the basics. I prefer a text-editor and ant (or even NetBeans). I never cared for IBM\'s approach IDEs before or after eclipse.

To be fair, eclipse isn\'t the only IDE or application that suffers from this problem. Most applications offer a powerful plugin system and are popular with plugin writers suffer from an inconsistent UI.

Adam · Mar 25, 06:36 PM · #

Commenting is closed for this article.