10

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?

3 Answers 3

11

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Maybe because it's stylish to use annotations over xml? (:
3

I know this question is rather old, but this may help someone coming from a search engine:

We recently undertook this endeavor in our own fairly large project and wrote a tool that parses hbm.xml-files and generates annotations into Java-files to help us.

You can find it here. It automates a majority of the migration, leaving you to only do the difficult parts. All the easy things are done for you.

Comments

2

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

2 Comments

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.
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.