• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Relations like Many to One in Hibernate and Database?

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do we represent Many to One/Many to Many relations of Hibernate in Database(Oracle)?

Do we need to write the hibernate code based on Database table or inversely? (i.e Which is first , creation of the tables in Database then Hibernate code (or) Creation of POJO classes in Hibernate then creation of tables?
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do it the way you like. Hibernate can create a schema from it's mapping files. But I would recommend that you (or your DBA) create tables first. In your development environment you can do it, but in production I think no DBA will let you generate tables. (Esp. in Oracle where you often want to put data and index into different tablespaces)
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your POJOs are mapped properly, you can just do a SchemaExport, and the underlying database will be created for you:



http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=02validatingthehibernateenvironment

It's a great way to create your database if you have the permissions to do it.

-Cameron McKenzie
reply
    Bookmark Topic Watch Topic
  • New Topic