2 Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 package com.mysql.clusterj.core.query;
21 import com.mysql.clusterj.Results;
22 import com.mysql.clusterj.core.*;
23 import com.mysql.clusterj.Query;
24 import com.mysql.clusterj.core.util.I18NHelper;
25 import com.mysql.clusterj.core.util.Logger;
26 import com.mysql.clusterj.core.util.LoggerFactoryService;
28 import java.util.List;
31 public class QueryImpl<E> implements Query<E> {
33 /** My message translator */
34 static final I18NHelper local = I18NHelper.getInstance(BetweenPredicateImpl.class);
37 static final Logger logger = LoggerFactoryService.getFactory().getInstance(BetweenPredicateImpl.class);
40 protected SessionImpl session;
42 /** My DomainObject */
43 protected QueryDomainTypeImpl<E> dobj;
45 /** My query execution context. */
46 protected QueryExecutionContextImpl context = null;
48 public QueryImpl(SessionImpl session, QueryDomainTypeImpl<E> dobj) {
49 this.session = session;
50 context = new QueryExecutionContextImpl(session);
54 public Results<E> execute(Object arg0) {
55 throw new UnsupportedOperationException(
56 local.message("ERR_NotImplemented"));
59 public Results<E> execute(Object... arg0) {
60 throw new UnsupportedOperationException(
61 local.message("ERR_NotImplemented"));
64 public Results<E> execute(Map<String, ?> arg0) {
65 throw new UnsupportedOperationException(
66 local.message("ERR_NotImplemented"));
69 public void setParameter(String parameterName, Object parameterValue) {
70 context.bindParameterValue(parameterName, parameterValue);
73 public List<E> getResultList() {
74 List<E> results = dobj.getResultList(context);
75 // create new context, copying the parameters, for another execution
76 context = new QueryExecutionContextImpl(context);
80 /** Delete the instances that satisfy the query criteria.
81 * @return the number of instances deleted
83 public int deletePersistentAll() {
84 int result = dobj.deletePersistentAll(context);
90 * @return the data about the execution of this query
92 public Map<String, Object> explain() {
93 Map<String, Object> result = context.getExplain();
95 dobj.explain(context);
96 return context.getExplain();