• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritence in hibernate

 
Rama Krishna Gaddipati
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pals,

Can any one tell me what are the main benifits if we used Inheritence in Hibernate.

Please reply me. Thanks in Advance.


Regards,
Ram
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the question really comes down to OO and not Hibernate. When in Java OO would you find inheritance better than composition, or just that inheritance is the way to go with OO?


The "Inheritance in Hibernate" is just that if you have an inheritance tree in Java then it is possible to map it to tables in Hibernate.

Mark
 
Rama Krishna Gaddipati
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we acheive any more in performance wise by using Inheritence in Hiberate?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rama Krishna Gaddipati:
Can we acheive any more in performance wise by using Inheritence in Hiberate?


Again, this isn't a Hibernate issue. Inheritance is Java Inheritance. However, you have your database designed, is what will determine any performance.

So here's a quick example

I have an Account class and two subclasses BankAccount and CreditCard. So how will that affect performance? Well in no way at all.

Performance will only be dictated by your database. Meaning do you have 1 table for this, or 2 tables or 3 tables, and if so will the query to the database need to include a join or not. And even if you have 1 2 or 3 tables, you could choose to create a class heirarchy or not, it wouldn't affect the query needed to run against the database.

Does that make more sense?

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic