tags:

views:

1957

answers:

3

I have a rather large program that uses Hibernate for its ORM needs. Due to the age of the project it is using hbm.xml to configure it. I would like to convert it to annotations but I'm vary of investing days (weeks?) in manually adding the annotations and then testing everything.

Is there any tool out there that can help facilitate this?

+4  A: 

I don't think so. But you don't have to do it in one go, you can mix annotation and .xml config quite easily.

Also, why do you feel the need to convert to annotations? I wouldn't say they're so much better than xml config to warrant the investment in time to convert them.

skaffman
+1  A: 

Have you looked at hibernate tools - specifically the hbm2java component?

mysomic
I already have the POJOs, automatically generating new ones from the DB scheme is not really an option, although this tool may be useful to me in future projects.
Kris
If they are simple entity POJOs then I can't see why you can't just overwrite them with those that hbm2java generates, or at the very least doing a merge between them. Surely it must beat going through each one adding the annotations by hand?
mysomic
A: 

You can do this with the hibernate eclipse plugin. Look under Run > Hibernate Code Generation. You could generate the annotated POJOs into a different folder, and then copy the annotations over to your existing POJOs. More info here: Hibernate Eclipse plugins.

jackocnr
The eclipse plugin seems perfectly happy to generate the java code but it doesn't seem to want to generate the annotations. Any tips?
Rob Oxspring