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

Performance of Hibernate Vs SQL Query in this scenario

 
Nikhil Sun
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have following classes



Now in my application code when I retrieve an instance of Jason class, as the fetch type of PersonTemplate,PersonAttribute are Lazy they would be retrieved only when required.

I want to retrieve the productCodeId variable in PersonAttribute class.
So I do the below thing:



How would the performance of above be as compared to if I write a straightforward SQL native query that joins the three tables to get the productCodeId?
Would the native SQL Query be better always than doing a jason.getPersonTemplate.personAttribute.getProductCodeId();??

Note: I may not be syntactically correct with the class definition annotations above, but I think you get an idea what I am trying to do
 
Gokul Nanthakumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every solution best fits to their unique requirements only. for small applications or programs always direct jdbc fits better than hibernate. for your example also jdbc is better approach if the utilization of the application is limited and the application size is very small. if you deploy the same solution in large volume and bigger applications with JDBC with out lazy loading, it will be a big performance problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic