MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbOpenJPAStoreQuery.java
1 /*
2  Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 
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.
7 
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.
12 
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
16 */
17 
18 package com.mysql.clusterj.openjpa;
19 
20 import com.mysql.clusterj.core.util.I18NHelper;
21 import com.mysql.clusterj.core.util.Logger;
22 import com.mysql.clusterj.core.util.LoggerFactoryService;
23 import org.apache.openjpa.jdbc.kernel.JDBCStoreQuery;
24 import org.apache.openjpa.jdbc.meta.ClassMapping;
25 import org.apache.openjpa.kernel.exps.ExpressionFactory;
26 import org.apache.openjpa.kernel.exps.ExpressionParser;
27 import org.apache.openjpa.kernel.exps.QueryExpressions;
28 import org.apache.openjpa.meta.ClassMetaData;
29 
33 @SuppressWarnings("serial")
34 public class NdbOpenJPAStoreQuery extends JDBCStoreQuery {
35 
37  static final I18NHelper local = I18NHelper.getInstance(NdbOpenJPAStoreQuery.class);
38 
41 
43  ExpressionParser expressionParser) {
44  super(storeManager, expressionParser);
45  }
46 
47  @Override
48  protected Number executeDelete(Executor ex, ClassMetaData base,
49  ClassMetaData[] metas, boolean subclasses, ExpressionFactory[] facts,
50  QueryExpressions[] exps, Object[] params) {
51  if (logger.isDebugEnabled()) {
52  logger.debug("NdbOpenJPAStoreQuery.executeDelete(Executor ex, ClassMetaData base, " +
53  "ClassMetaData[] metas, boolean subclasses, ExpressionFactory[] facts, " +
54  "QueryExpressions[] exps, Object[] params).\n" +
55  "Class: " + base.getTypeAlias() +
56  " query expressions: " + exps + "[" + exps.length + "]" +
57  " exps[0].filter: " + exps[0].filter);
58  }
60  NdbOpenJPADomainTypeHandlerImpl<?> domainTypeHandler = store.getDomainTypeHandler((ClassMapping)base);
61  if (domainTypeHandler.isSupportedType()
62  && exps.length == 1
63  && exps[0].filter.getClass().getName().contains("EmptyExpression")) {
64  // filter is empty so delete the entire extent
65  if (logger.isDebugEnabled()) {
66  logger.debug("Empty Expression for delete will delete the entire extent.");
67  }
68  int count = store.deleteAll(domainTypeHandler);
69  return count;
70  } else {
71  if (logger.isDebugEnabled()) logger.debug("NdbOpenJPAStoreQuery.executeDelete delegated to super.");
72  return super.executeDelete(ex, base, metas, subclasses, facts, exps, params);
73  }
74  }
75 
76 }