Reputation: 66
Discussion on hibernate which I can use in my project;
Case1: I have a simple query case:
select <column> from <table> where <condition>
For this case, which facility of hibernate can I use - find by named query or use criteria/detached criteria - which one will be better for performance.
Case2: For join query cases, which facility would be most efficient: criteria/detached criteria or use a reference VO [referring to foreign key table] inside my parent VO[referring to parent Table]
Upvotes: 1
Views: 715
Reputation: 21113
Case1: I have a simple query case: select from where
For this case, which facility of hibernate can I use - find by named query or use criteria/detached criteria - which one will be better for performance.
The only performance difference you will see between the two is based on query parse time. In the case of a Named Query the query will be parsed at bootup of hibernate once and reused. If you used a Criterion Query the query will be parsed at each execution point at runtime.
Case2: For join query cases, which facility would be most efficient: criteria/detached criteria or use a reference VO [referring to foreign key table] inside my parent VO[referring to parent Table]
Unless your join-query is again a named query, you're going to incur the same performance issues as above, mainly in the area of parsing the query into SQL.
As for whether you elect to use the Hibernate/JPA criteria API or JPQL/HQL; it's really a matter of taste.
The most crucial performance concern you likely should be considering when using an ORM is to make sure your fetch strategies are adequate and that the proper joins are used to avoid things such as N+1 SELECT concerns.
Making adequate use of tuple-queries or construct-new value-object queries can go a long way to minimize network bandwidth when the entities being queried are wide and you have several being joined together for some UI view.
Upvotes: 1