I have a Java application using Hibernate to communicate with a MsSQL 2005 server, the driver is net.sourceforge.jtds 1.2.4.
Things are working but the performance is horrible, I suspect the index isn't used for the queries passed to it, since the response times are proportional to the number of entries in the table.
I have written a small test application that use the same driver (jtds) but doesn't use Hibernate and I have been able to reproduce the poor performance (or so I believe). When I use a prepared statements I see the same poor performance as using Hibernate (response times of ~1s), but when I don't the performance is great (~10ms).
I am able to get the same good performance using the Hibernate executeSql
method instead of the Criteria
interface, but I want to avoid this since I want the code to stay modular and also the results are not converted to my entity class.
Is there some way to have the good performance with Hibernate, while still using a backend-agnostic way of making queries and having the results converted to entity class objects?