java/code/src/com/redhat/rhn/domain/server/ServerFactory.java | 31 +++++++---
1 file changed, 22 insertions(+), 9 deletions(-)
New commits:
commit 5073c7dd19a65d1b0cc15854d6e88e1f65eef003
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Sep 29 17:14:53 2009 -0400
workaround for hibernate not handling in caluses of more than 1000
diff --git a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
index a6092dc..6b27799 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
@@ -748,12 +748,31 @@ public class ServerFactory extends HibernateFactory {
* @return list of system ids that are solaris systems
*/
public static List<Long> listSolarisSystems(Collection<Long> systemIds)
{
+ return listGenericSystems(systemIds, "Server.listSolarisSystems");
+ }
+
+
+
+ private static List<Long> listGenericSystems(Collection<Long> systemIds,
String query) {
//Hibernate can't handle empty lists for in clauses, silly hibernate
if (systemIds.isEmpty()) {
return Collections.EMPTY_LIST;
}
- return
ServerFactory.getSession().getNamedQuery("Server.listSolarisSystems").
- setParameterList("sids", systemIds).list();
+ ArrayList<Long> tmpList = new ArrayList<Long>();
+ List<Long> toRet = new ArrayList<Long>();
+ tmpList.addAll(systemIds);
+
+ for (int i = 0; i < systemIds.size();) {
+ int initial = i;
+ int fin = i + 500 < systemIds.size() ? i + 500 : systemIds.size();
+ List<Long> sublist = tmpList.subList(i, fin);
+ toRet.addAll(ServerFactory.getSession().getNamedQuery(query).
+ setParameterList("sids", sublist).list());
+ i = fin+1;
+ }
+
+ return toRet;
+
}
/**
@@ -763,13 +782,7 @@ public class ServerFactory extends HibernateFactory {
* @return list of system ids that are linux systems
*/
public static List<Long> listLinuxSystems(Collection<Long> systemIds) {
- //Hibernate can't handle empty lists for in clauses, silly hibernate
- if (systemIds.isEmpty()) {
- return Collections.EMPTY_LIST;
- }
- return
ServerFactory.getSession().getNamedQuery("Server.listRedHatSystems").
- setParameterList("sids",
systemIds).list();
-
+ return listGenericSystems(systemIds, "Server.listRedHatSystems");
}
}
Show replies by date