您好我想使用Restrictions.in
在我的数据库中查找对象Criteria c = s.createCriteria(MyClass.class);
c.add(Restrictions.in("id", hugeidlist));
return c.list();
该列表包含超过100,000个条目(大部分将在数据库中不可用),这使得hibernate死亡
http-bio-8080-exec-5 03/06/2014 16:05:59,346 | WARN | org.hibernate.engine.jdbc.spi.SqlExceptionHelper | logExceptions | SQL Error: 0, SQLState: 08006
http-bio-8080-exec-5 03/06/2014 16:05:59,351 | ERROR | org.hibernate.engine.jdbc.spi.SqlExceptionHelper | logExceptions | An I/O error occured while sending to the backend.
http-bio-8080-exec-5 03/06/2014 16:05:59,353 | WARN | com.mchange.v2.c3p0.impl.NewPooledConnection | handleThrowable | [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
http-bio-8080-exec-5 03/06/2014 16:05:59,354 | WARN | com.mchange.v2.c3p0.impl.NewPooledConnection | handleThrowable | [c3p0] Another error has occurred [ org.postgresql.util.PSQLException: This connection has been closed. ] which will not be reported to listeners!
org.postgresql.util.PSQLException: This connection has been closed.
我能做什么?
答案 0 :(得分:0)
答案是否定的。发送大量查询将非常缓慢,而在Oracle上,由于很好的理由,您的查询列表限制在1000 IN。
如果您知道数据库中不包含许多数据库,那么您最好从数据库中选择ID并在Java中进行匹配。
更快,更可靠,并且在您的生产环境中不会失败。