com.jk.data.dataaccess.orm.JKObjectDataAccess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jk-framework-data Show documentation
Show all versions of jk-framework-data Show documentation
This contains a set of API's that ease the database programming with Java, in both: JDBC and JPA Persisitnce).
/*
* Copyright 2002-2022 Dr. Jalal Kiswani.
* Email: [email protected]
* Check out https://smart-api.com for more details
*
* All the opensource projects of Dr. Jalal Kiswani are free for personal and academic use only,
* for commercial usage and support, please contact the author.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jk.data.dataaccess.orm;
import java.util.List;
import java.util.Map;
import com.jk.core.util.JK;
// TODO: Auto-generated Javadoc
/**
* The Interface JKObjectDataAccess.
*/
public interface JKObjectDataAccess {
/**
* Insert.
*
* @param the generic type
* @param object the object
* @return the t
*/
public T insert(T object);
/**
* Update.
*
* @param the generic type
* @param object the object
* @return the t
*/
public T update(T object);
/**
* Delete.
*
* @param the generic type
* @param object the object
* @return the t
*/
public T delete(T object);
/**
* Delete.
*
* @param the generic type
* @param type the type
* @param id the id
* @return the t
*/
public T delete(Class type, Object id);
/**
* Find.
*
* @param the generic type
* @param clas the clas
* @param id the id
* @return the t
*/
public T find(Class clas, Object id);
/**
* Gets the list.
*
* @param the generic type
* @param clas the clas
* @return the list
*/
public List getList(Class clas);
/**
* Gets the list.
*
* @param the generic type
* @param clas the clas
* @param paramters the paramters
* @return the list
*/
public List getList(Class clas, Map paramters);
/**
* Execute query.
*
* @param the generic type
* @param clas the clas
* @param queryString the query string
* @param paramters the paramters
* @return the list
*/
public List executeQuery(Class clas, String queryString, Object... paramters);
/**
* Find by field name.
*
* @param the generic type
* @param clas the clas
* @param fieldName the field name
* @param value the value
* @return the list
*/
public List findByFieldName(Class clas, String fieldName, Object value);
/**
* Insert or update.
*
* @param the generic type
* @param object the object
* @return the t
*/
public T insertOrUpdate(T object);
/**
* Find one by field name.
*
* @param the generic type
* @param clas the clas
* @param fieldName the field name
* @param fieldValue the field value
* @return the t
*/
public T findOneByFieldName(Class clas, String fieldName, Object fieldValue);
/**
* Sets the max results.
*
* @param maxResults the new max results
*/
public void setMaxResults(int maxResults);
/**
* Detach.
*
* @param the generic type
* @param model the model
*/
public void detach(T model);
/**
* Clone.
*
* @param the generic type
* @param model the model
* @return the t
*/
public T clone(T model);
/**
* Start transaction.
*/
public void startTransaction();
/**
* Close transaction.
*
* @param commit the commit
*/
public void closeTransaction(boolean commit);
/**
* Execute single output query.
*
* @param the generic type
* @param clas the clas
* @param query the query
* @param params the params
* @return the t
*/
public default T executeSingleOutputQuery(Class clas, String query, Object... params) {
List list = executeQuery(clas, query, params);
if (list.size() > 1) {
JK.exception("Query returned more than one row : " + query);
}
if (list.size() == 1) {
return list.get(0);
}
return null;
}
/**
* Gets the list and cache.
*
* @param the generic type
* @param clas the clas
* @return the list and cache
*/
public List getListAndCache(Class clas);
}