001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.core.framework.persistence.dao; 017 018import java.util.Collection; 019import java.util.List; 020import java.util.Map; 021 022/** 023 * This is the generic data access interface for business objects. 024 * This class was adapted from the Kuali Nervous System 025 * (org.kuali.rice.krad.dao.BusinessObjectDao). 026 * It's not as generic as it could be as it relies on the OJB criteria object... 027 * 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 * @deprecated use new KRAD Data framework {@link org.kuali.rice.krad.data.DataObjectService} 030 */ 031@Deprecated 032public interface GenericDao { 033 /** 034 * Saves any object 035 * 036 * @param bo 037 */ 038 public void save(Object bo); 039 040 /** 041 * Saves a List of objects 042 * 043 * @param businessObjects 044 */ 045 public void save(List businessObjects); 046 047 /** 048 * Retrieves an object instance identified bys it primary key. 049 * 050 * @param clazz the class 051 * @param id the primary key value 052 * @return Object 053 */ 054 public Object findById(Class clazz, Object keyValue); 055 056 /** 057 * Retrieves an object instance identified by its primary keys and 058 * values. This can be done by constructing a map where the key to the 059 * map entry is the primary key attribute and the value of the entry 060 * being the primary key value. For composite keys, pass in each 061 * primaryKey attribute and its value as a map entry. 062 * 063 * @param clazz 064 * @param primaryKeys 065 * @return Object 066 */ 067 public Object findByPrimaryKey(Class clazz, Map primaryKeys); 068 069 /** 070 * This method should be used to try and locate an object instance by passing 071 * in unique keys and values. This can be done by constructing a map where the key to the 072 * map entry is the unique key attribute and the value of the entry 073 * being the unique key value. For composite keys, pass in each 074 * unique key attribute and its value as a map entry. 075 * 076 * @param clazz 077 * @param uniqueKeys 078 * @return Object 079 */ 080 public Object findByUniqueKey(Class clazz, Map uniqueKeys); 081 082 /** 083 * Retrieves an object instance identified by the class of the given 084 * object and the object's primary key values. 085 * 086 * @param object 087 * @return Object 088 */ 089 public Object retrieve(Object object); 090 091 /** 092 * This method allows you to pass in an object that has some fields filled in, 093 * and will query underneath by automatically constructing a select statement 094 * whose where clause is built automatically by looking at the non-null 095 * attributes and using their values as part of the query. This is basically 096 * a query by "template" method. 097 * @param object 098 * @return Collection 099 */ 100 public Collection findMatchingByExample(Object object); 101 102 /** 103 * Retrieves a collection of business objects populated with data, such 104 * that each record in the database populates a new object instance. 105 * This will only retrieve business objects by class type. 106 * 107 * @param clazz 108 * @return Collection 109 */ 110 public Collection findAll(Class clazz); 111 112 /** 113 * Retrieves a collection of business objects populated with data, such 114 * that each record in the database populates a new object instance. 115 * This will only retrieve business objects by class type. Orders the 116 * results by the given field. 117 * 118 * @param clazz 119 * @return Collection 120 */ 121 public Collection findAllOrderBy(Class clazz, String sortField, 122 boolean sortAscending); 123 124 /** 125 * This method retrieves a collection of business objects populated with 126 * data, such that each record in the database populates a new object 127 * instance. This will retrieve business objects by class type and also 128 * by criteria passed in as key-value pairs, specifically attribute 129 * name-expected value. 130 * 131 * @param clazz 132 * @param fieldValues 133 * @return Collection 134 */ 135 public Collection findMatching(Class clazz, Map fieldValues); 136 137 /** 138 * This method allows for a more flexible search by allowing the programmer to 139 * construct the criteria however they need to and then pass that in for execution. 140 * @param clazz 141 * @param criteria 142 * @return Collection 143 */ 144 public Collection findMatching(Class clazz, org.apache.ojb.broker.query.Criteria criteria); 145 146 /** 147 * This method allows for a more flexible search by allowing the programmer to 148 * construct the criteria however they need to and then pass that in for execution. 149 * @param clazz 150 * @param criteria 151 * @param selectForUpdate whether to perform a select for update query 152 * @param wait millis to wait for select for update 153 * @return Collection 154 */ 155 public Collection findMatching(Class clazz, org.apache.ojb.broker.query.Criteria criteria, boolean selectForUpdate, long wait); 156 157 public Collection findMatching(Class clazz, Map criteria, boolean selectForUpdate, long wait); 158 159 /** 160 * @param clazz 161 * @param fieldValues 162 * @return count of BusinessObjects of the given class whose fields 163 * match the values in the given Map. 164 */ 165 public int countMatching(Class clazz, Map fieldValues); 166 167 /** 168 * 169 * This method returns the number of matching result given the positive 170 * criterias and negative criterias. The negative criterias are the ones 171 * that will be set to "notEqualTo" or "notIn" 172 * 173 * @param clazz 174 * @param positiveFieldValues 175 * Map of fields and values for positive criteria 176 * @param negativeFieldValues 177 * Map of fields and values for negative criteria 178 * @return int 179 */ 180 public int countMatching(Class clazz, Map positiveFieldValues, 181 Map negativeFieldValues); 182 183 /** 184 * This method retrieves a collection of business objects populated with 185 * data, such that each record in the database populates a new object 186 * instance. This will retrieve business objects by class type and also 187 * by criteria passed in as key-value pairs, specifically attribute 188 * name-expected value. Orders the results by the given field. 189 * 190 * @param clazz 191 * @param fieldValues 192 * @return Collection 193 */ 194 public Collection findMatchingOrderBy(Class clazz, Map fieldValues, 195 String sortField, boolean sortAscending); 196 197 /** 198 * Deletes a business object from the database. 199 * 200 * @param bo 201 */ 202 public void delete(Object bo); 203 204 /** 205 * Deletes each business object in the given List from the database. 206 * 207 * @param boList 208 */ 209 public void delete(List<Object> boList); 210 211 /** 212 * Deletes the business objects matching the given fieldValues 213 * 214 * @param clazz 215 * @param fieldValues 216 */ 217 public void deleteMatching(Class clazz, Map fieldValues); 218 219}