
com.enterprisemath.dao.object.ObjectCRUDDao Maven / Gradle / Ivy
package com.enterprisemath.dao.object;
import com.enterprisemath.dao.big.BigEntityDao;
import com.enterprisemath.dao.filter.Criterium;
import com.enterprisemath.dao.filter.Filter;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Object level layer for universal CRUD operation with objects.
* This is the generic layer for objects. Purpose is to standardized and decrease the amount of code where possible.
* Drawback is that implementation might have particular requirements for objects, underlying storage schema,
* might not support all use cases and performance wise it is most likely slower than the lower layer units.
* Therefore please consider these and fall into lower layer implementation if needed (e.g. BigEntityDao).
*
*
* Note: Adding functions to this interface will NOT be
* considered as breaking binary compatibility.
*
*
* @see BigEntityDao
* @author radek.hecl
*/
public interface ObjectCRUDDao {
/**
* Inserts object.
*
* @param object type
* @param object object
*/
public void insert(T object);
/**
* Inserts object with extra fields.
*
* @param object type
* @param object main object
* @param extra extra fields binded to the main object
*/
public void insert(T object, Map extra);
/**
* Inserts objects with extra fields.
*
* @param object type
* @param object main object
* @param extraFirst first object with extra data
* @param extraOthers others objects with extra data
*/
public void insert(T object, Object extraFirst, Object... extraOthers);
/**
* Selects single object. Throws an exception if there is no object or if there are more than 1 objects.
*
* @param object type
* @param filter type
* @param clazz object class
* @param column filter column (must be equivalent to unique key)
* @param value filter value
* @return selected object
*/
public T selectSingle(Class clazz, F column, Object value);
/**
* Selects single object. Returns default object if there is no object presented in the database.
* Throws an exception if there is no unique object.
*
* @param object type
* @param filter type
* @param clazz object class
* @param column filter column (must be equivalent to unique key)
* @param value filter value
* @param def default object
* @return selected object or default value if object doesn't exists
*/
public T selectSingle(Class clazz, F column, Object value, T def);
/**
* Selects list of objects.
*
* @param object type
* @param filter type
* @param clazz result object class
* @param filter filter
* @return selected objects
*/
public List selectList(Class clazz, Filter filter);
/**
* Selects extra fields of the given object.
*
* @param object type
* @param filter type
* @param clazz object class
* @param code object identification code
* @param fields fields to select
* @return selected fields
*/
public Map selectExtra(Class clazz, String code, Map> fields);
/**
* Selects extra fields of the given object.
*
* @param main object type
* @param class for the extra fields
* @param filter type
* @param clazz object class
* @param code object identification code
* @param extraClazz class which identifies the extra fields
* @return selected object
*/
public E selectExtra(Class clazz, String code, Class extraClazz);
/**
* Updates whole object.
*
* @param object type
* @param object object
*/
public void update(T object);
/**
* Performs partial update.
*
* @param object type
* @param clazz object class
* @param code object identification code
* @param fields fields to update
*/
public void update(Class clazz, String code, Map fields);
/**
* Performs partial update.
*
* @param main object type
* @param partial update tye
* @param clazz object class
* @param code object identification code
* @param update update object, if update contains property code, then it must be equal to the given code
*/
public void update(Class clazz, String code, E update);
/**
* Deletes single object.
*
* @param object type
* @param clazz object class
* @param code object identification code
*/
public void delete(Class clazz, String code);
/**
* Deletes all objects which matches the criteria.
*
* @param object type
* @param filter type
* @param clazz object class
* @param criteria criteria
*/
public void deleteAll(Class clazz, Set> criteria);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy