I wonder why Hibernate and/or Spring apparently adds a lot of overhead for queries. I have Spring Framework 1.2.5 with Hibernate 3 support.
When I run the following query on a table with 144 rows in it:
Code:
List<Resource> resourceList = getHibernateTemplate().find("from Resource");
or
Code:
List<Resource> resourceList = getSession().createSQLQuery("select * from RESOURCE").addEntity(Resource.class).list();
the query takes 120 ms to execute.
When I run
Code:
Connection connection = getSession().connection();
PreparedStatement statement = connection.prepareStatement("select * from RESOURCE");
ResultSet rs = statement.executeQuery();
the query only takes 1 ms!
Am I doing something wrong?
/Patrik