I use Criteria with Restrictions.in(String name, Collection ids) to select the list of MyClass objects from the MyTable table (SQLServer 2005). If the length of the Collection ids is more than 2097 (I checked the number several times!) then I get the exception:
com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
org.hibernate.loader.Loader.doQuery(Loader.java:674)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
org.hibernate.loader.Loader.doList(Loader.java:2220)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
org.hibernate.loader.Loader.list(Loader.java:2099)
org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
Here is the code:
<hibernate-mapping> <class name="MyClass" table="MyTable"> <id name="id" column="id"/> </class> </hibernate-mapping>
List<Long> ids = new ArrayList<Long>(); for ( int i = 0; i < 2098; i++ ) { ids.add( new Long( i ) ); } Criteria cr = session.createCriteria( MyClass.class ).add( Restrictions.in("id", ids ) ); List<MyClass> list = cr.list();// the Exception is raised here
|