• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Creating class files and Hibernate mappings from database

 
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.
 
Author
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
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..
 
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.
 
rubbery bacon. rubbery tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic