View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.data.jpa;
17  
18  import org.kuali.rice.core.api.criteria.GenericQueryResults;
19  import org.kuali.rice.core.api.criteria.QueryByCriteria;
20  
21  /**
22   * Simple interface that abstracts ORM query by criteria and delete logic.
23   *
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  interface CriteriaQuery {
27      /**
28       * Looks up a type based on a query criteria.
29       *
30       * @param queryClass the class to lookup
31       * @param criteria the criteria to lookup against. cannot be null.
32       * @param <T> the type that is being looked up.
33       * @return the results. will never be null.
34       * @throws IllegalArgumentException if the criteria is null
35       */
36      <T> GenericQueryResults<T> lookup(final Class<T> queryClass, final QueryByCriteria criteria);
37  
38      /**
39       * Deletes all data objects based on the given type.
40       *
41       * @param type the type of data objects to delete
42       * @param <T> the data object class type
43       *
44       * @throws IllegalArgumentException if the class type is null
45       * @throws org.springframework.dao.DataAccessException if data access fails
46       */
47      public <T> void deleteAll(Class<T> type);
48  
49  
50      /**
51       * Deletes data objects based on the given criteria
52       *
53       * <p>If the given criteria is empty or null than an {@link java.lang.IllegalArgumentException} will be thrown.
54       *   If the given type is null then an {@link java.lang.IllegalArgumentException} will be thrown.</p>
55       *
56       * @param type the type of data object
57       * @param criteria criteria to filter by
58       *
59       * @throws IllegalArgumentException if the criteria or criteria predicate is null
60       * @throws org.springframework.dao.DataAccessException if data access fails
61       */
62      public <T> void deleteMatching(Class<T> type, QueryByCriteria criteria);
63  
64  }