Deep
Deep

Reputation: 11

Database Tables from POJOs

Is there any way or any utility to generate hibernate mapping files or directly the database tables from POJOs. I cannot manually insert hibernate annotations since these POJOs are generated dynamically in my application. Please suggest a solution.

Upvotes: 1

Views: 2182

Answers (3)

kabuski
kabuski

Reputation: 11

What I do is this:

  1. use a scaffolding application like Grails (ay would do Rails, Sails, etc).
  2. Then reverse Engineer them into pojos via Eclipse

It works everytime and using Grails is fast and VERY easy to use.

Upvotes: 0

Timo Westkämper
Timo Westkämper

Reputation: 22190

Alternatively you could change your code generation in your application to include the javax.persistence annotations.

Upvotes: 1

Fried Hoeben
Fried Hoeben

Reputation: 3272

Instead of using annotations you could also use 'old fashioned' .hbm.xml mapping files. This is the classic way of defining a mapping with Hibernate which uses an external xml file to describe the mapping. You could generate the mappings at the same time when you generate your POJOs. Or if the POJO generation is done by external code you could add this yourself.

Once you have a mapping you can use the standard Hibernate facilities to create/upgrade the database schema...

Upvotes: 1

Related Questions