Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating class files and Hibernate mappings from database

 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an existing database. Now I'd like to use Hibernate to connect to the database, but I can't make any changes to the table format.

What I'm looking for is a script, Eclipse plugin or somesuch, that I can point to the database and have it create the pojo's and Hibernate mapping.

Does this exist? So far I haven't been able to find anything of the sort.

TIA.
 
Javid Jamae
Author
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at this: http://www.hibernate.org/255.html

But, depending on what your DB structure looks like, this may be a bad idea. You often don't want an object model that looks like a database schema. Your object model will often be much more "normalized" and will use more domain-friendly names than your DB might. You probably want to design a proper object model for your application, then use a tool to map the schema to your objects. But generally, writing the mapping files (or annotations) are so straight-forward, so I don't even bother with the tools.
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javid Jamae wrote:Look at this: http://www.hibernate.org/255.html

But, depending on what your DB structure looks like, this may be a bad idea. You often don't want an object model that looks like a database schema. Your object model will often be much more "normalized" and will use more domain-friendly names than your DB might. You probably want to design a proper object model for your application, then use a tool to map the schema to your objects. But generally, writing the mapping files (or annotations) are so straight-forward, so I don't even bother with the tools.


-nods- I doubt I'll use the setup as is. I mostly want it for a starting point, and then I can tweak to suit.

I downloaded the Eclipse tools, but so far I haven't had much luck with getting them to work. Do you have any pointers?
 
Javid Jamae
Author
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I haven't used it before. I'm an old-fashioned code-it-by-hand kinda guy..
 
S Rahim
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Try the procedure http://www.wikihow.com/Generate-Hibernate-Pojo-Classes-from-DB-Tables for Eclipse (have not tried myself)
OR
for netbeans (better get 6.5 )
http://wiki.netbeans.org/ReverseEngineering (tried and works)

redsword
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S Rahim wrote:
Try the procedure http://www.wikihow.com/Generate-Hibernate-Pojo-Classes-from-DB-Tables for Eclipse (have not tried myself)
OR
for netbeans (better get 6.5 )
http://wiki.netbeans.org/ReverseEngineering (tried and works)

redsword


I'll take a look. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic