1 56 package org.objectstyle.cayenne.service; 57 58 import java.util.List ; 59 60 import org.objectstyle.cayenne.access.PersistenceContext; 61 import org.objectstyle.cayenne.access.QueryResult; 62 import org.objectstyle.cayenne.map.EntityResolver; 63 import org.objectstyle.cayenne.query.Query; 64 import org.objectstyle.cayenne.query.QueryExecutionPlan; 65 66 72 class PersistenceContextQueryAction { 73 74 EntityResolver resolver; 75 76 public PersistenceContextQueryAction(EntityResolver resolver) { 77 this.resolver = resolver; 78 } 79 80 QueryResult performMixed(PersistenceContext context, QueryExecutionPlan query) { 81 Query resolvedQuery = query.resolve(resolver); 82 83 QueryResult resultCallback = new QueryResult(); 84 context.performQuery(resolvedQuery, resultCallback); 85 return resultCallback; 86 } 87 88 int[] performNonSelectingQuery(PersistenceContext context, QueryExecutionPlan query) { 89 90 Query resolvedQuery = query.resolve(resolver); 91 92 QueryResult resultCallback = new QueryResult(); 93 context.performQuery(resolvedQuery, resultCallback); 94 95 List updateCounts = resultCallback.getUpdates(resolvedQuery); 96 if (updateCounts == null || updateCounts.isEmpty()) { 97 return new int[0]; 98 } 99 100 int len = updateCounts.size(); 101 int[] counts = new int[len]; 102 103 for (int i = 0; i < len; i++) { 104 counts[i] = ((Number ) updateCounts.get(i)).intValue(); 105 } 106 107 return counts; 108 } 109 } 110 | Popular Tags |