Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

hibernate newbie question , no of pojo classes = no of tables in database ????

 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi , i am newbie in hibernate , my question is as follows ,

suppose there are 10 tables in the databas which are joined in some way ,
than we have to make 10 java pojo class
than we will map each java class to database table

can anyone please tell me am i thinking in right direction
thanks
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the simplest cases, yes, you will have one pojo per table.

However, that is somewhat the point of object/relational mapping. If your table space (schema) does not match your business derived space (objects) then you may "fix" it in the mapping. Look at a Hibernate "component" as an example.

There are all sorts of issues/tradeoffs here so if you are just getting your feet wet, then you will most likely find tutorials that map a table to a pojo. Also, if you are dealing with a mature database schema, then you will find a lot of one to one correspondence. However, if the schema has been heavily normalized, you may end up with too many pojos that don't make sense in your object world.

Hope this helps.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, you will find that you want your Objects to be as OO like as possible, if you do a one to one relationship between tables and objects, you are most likely not being completely OO. I say most likely, because if you have a small amount of tables, it might come out to 1 to 1. But with Inheritence and Value Types, you can find you will have more Java objects than tables.

The other reason I say that, is you are designing your object model based on the tables, instead of designing your obects thinking in OO, which is not a great idea.

Mark
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic