Question

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?

Was it helpful?

Solution

Have you tried the proprietary driver from Microsoft? You can download it here. And an overview of the supported configurations is shown here. It might give you better performance.

A related post on SO might also be of help to you: how to configure hibernate config file for sql server

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top