Hi,

I got weird errors with hibernate (2.1.8) using it to
access SQL Server 2000 with the jTDS driver (1.0). It
complained about a FORWARD_ONLY resultset. The weird
thing was that my app was running perfectly until I
changed a varchar field to nvarchar and the errors
seemed quite random.

After playing around a bit it turned out that jtds
tried in the first place to get a cursor, failing down
to use a custom resultset if that was not possible,
and this recordset is of type FORWARD_ONLY. So,
depending of the actual results you get, the same
query can throw an exception or not.

The patch makes the Loader check the actual type of
the resultset, besides checking the requested size.

Although each jdbc driver has its own implementation
of the getType() method I think is safe to assume that
it is lightweight enough so as no to incur in
performance penalty.

Regards,
Pedro


                
______________________________________________ 
Renovamos el Correo Yahoo!: ˇ250 MB GRATIS! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es
diff -ruN src_orig/net/sf/hibernate/loader/Loader.java src/net/sf/hibernate/loader/Loader.java
--- src_orig/net/sf/hibernate/loader/Loader.java	2005-02-02 17:37:38.000000000 +0100
+++ src/net/sf/hibernate/loader/Loader.java	2005-02-02 16:58:13.000000000 +0100
@@ -703,7 +703,7 @@
 		
 		int firstRow = getFirstRow(selection);
 		if ( firstRow!=0 ) {
-			if ( session.getFactory().isScrollableResultSetsEnabled() ) {
+			if ( session.getFactory().isScrollableResultSetsEnabled() && rs.getType() != ResultSet.TYPE_FORWARD_ONLY) {
 				// we can go straight to the first required row
 				rs.absolute(firstRow);
 			}

Reply via email to