This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Transfer Learning for Natural Language Processing (MEAP) and have Paul Azunre on-line!
See this thread for details.
Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

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.
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic