If you have performance issues, then use the JDBC code.
There are a number of well-known pure SQL optimizations that would be very difficult to do in Hibernate.
Select only the columns you are using! (No "select *").
Keep SQl as simple as possible. for example Do not include small reference tables, such as currency codes in the connection. Instead, load the currency table into memory and define the currency descriptions using the program search.
Depending on the minor override of the SQL DBMS, where predicates can significantly affect performance.
If you update / insert, make only every 100 - 1000 updates. those. Do not do every unit of work, but keep a counter so that you do less often.
Take advantage of the aggregate features of your database. If you want to get the total values ββfor the DEPT code, then do it in SQL with "SUM (quantity) ... GROUP BY DEPT".
James anderson
source share