java/code/src/com/redhat/rhn/common/db/datasource/xml/SystemGroup_queries.xml | 18
++---
java/code/src/com/redhat/rhn/domain/server/ServerFactory.java | 32
++++++++--
2 files changed, 36 insertions(+), 14 deletions(-)
New commits:
commit 7c9d5dd3a5c3d975f406215b4af7c5bcbddbf9d8
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 06787c9..ebc36a8 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
@@ -771,12 +771,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;
+
}
/**
@@ -786,13 +805,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");
}
}
commit 090c5f3ad8a4c6270b0047ed86dff35758b56263
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Sep 29 16:35:00 2009 -0400
query fix for groups page
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/SystemGroup_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/SystemGroup_queries.xml
index 39d7ecf..f85288f 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/SystemGroup_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/SystemGroup_queries.xml
@@ -23,27 +23,27 @@
( SELECT 1 from dual where exists
- (select 1 FROM rhnErrata E,
- rhnServerNeededPackageCache SNPC,
- rhnServerGroupMembers SGM
+ (select /*+ ORDERED */ 1 FROM rhnServerGroupMembers SGM,
+ rhnServerNeededErrataCache SNPC,
+ rhnErrata E
WHERE E.advisory_type = 'Security Advisory'
and snpc.errata_id = e.id
and snpc.server_id = sgm.server_id
and sgm.server_group_id = G.id)) AS SECURITY_ERRATA,
(SELECT 1 from dual where exists
- (select 1 FROM rhnErrata E,
- rhnServerNeededPackageCache SNPC,
- rhnServerGroupMembers SGM
+ (select /*+ ORDERED */ 1 FROM rhnServerGroupMembers SGM,
+ rhnServerNeededErrataCache SNPC,
+ rhnErrata E
WHERE E.advisory_type = 'Bug Fix Advisory'
and snpc.errata_id = e.id
and snpc.server_id = sgm.server_id
and sgm.server_group_id = G.id)) AS BUG_ERRATA,
(SELECT 1 from dual where exists
- (select 1 FROM rhnErrata E,
- rhnServerNeededPackageCache SNPC,
- rhnServerGroupMembers SGM
+ (select /*+ ORDERED */ 1 FROM rhnServerGroupMembers SGM,
+ rhnServerNeededErrataCache SNPC,
+ rhnErrata E
WHERE E.advisory_type = 'Product Enhancement Advisory'
and snpc.errata_id = e.id
and snpc.server_id = sgm.server_id
commit 7e51e6b06314e5a01e1c028f6d1221017ff27297
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Sep 29 11:53:47 2009 -0400
adding workaround for hibernate oddity/bug
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 7ce8f0b..06787c9 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
@@ -40,6 +40,7 @@ import org.hibernate.Session;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
@@ -770,6 +771,10 @@ public class ServerFactory extends HibernateFactory {
* @return list of system ids that are solaris systems
*/
public static List<Long> listSolarisSystems(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.listSolarisSystems").
setParameterList("sids", systemIds).list();
}
@@ -781,6 +786,10 @@ 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();
Show replies by date