• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Relations like Many to One in Hibernate and Database?  RSS feed

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • 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
  • 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: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!