Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why use hibernate mapping when we can fetch from second table by using HQL

 
Monica Shiralkar
Ranch Hand
Posts: 873
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I have to fetch categories from products. We can do by forming an HQL without any hibernate mapping. Then what is the advantage of instead doing a hibernate mapping.


In hibernate we can fetch from the second table using a HQL select query. Such a query does not require hibernate mapping.Then what is the advantage of using mapping.


thanks
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
If I understand your question right then could you tell me why would you use Hibernate to retrieve data from database ? why not plain JDBC and ResultSet/SQL ?

Regards,
Amit
 
Monica Shiralkar
Ranch Hand
Posts: 873
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Amit. It is used so that later if database changes same code can be used.
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
IMO, using hibernate to only address changing database problem is overkill. I would use some other lightweight framework like Spring JDBC Template and iBatis ( not sure if its being updated anymore).

Unless you are building a product I do not think we have to be concerned about backend database changing too often.

Regards,
Amit
 
Monica Shiralkar
Ranch Hand
Posts: 873
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO, using hibernate to only address changing database problem is overkill. I would use some other lightweight framework like Spring JDBC Template and iBatis ( not sure if its being updated anymore).


I read on the internet that this is the primary advantage of using hibernate. If you say that this should not be the primary reason then what else can be the primary reason for using hibernate?

thanks
 
Dave Tolls
Ranch Hand
Posts: 2102
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica. Shiralkar wrote:
IMO, using hibernate to only address changing database problem is overkill. I would use some other lightweight framework like Spring JDBC Template and iBatis ( not sure if its being updated anymore).


I read on the internet that this is the primary advantage of using hibernate. If you say that this should not be the primary reason then what else can be the primary reason for using hibernate?

thanks


It's an ORM tool, so that's the primary reason for using it.
The "no worries about changing databases" was only ever a distant secondary.
 
Monica Shiralkar
Ranch Hand
Posts: 873
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic