Class GenericDelegator
- All Implemented Interfaces:
DelegatorInterface
- Direct Known Subclasses:
LockedDatabaseGenericDelegator
TODO The thread safety in here (and everywhere in ofbiz) is crap, improper double checked locking, modification of maps while other threads may be reading them, this class is not thread safe at all.
- Since:
- 1.0
- Author:
- David E. Jones, Chris Maurer, Andy Zeneski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final UtilCache<String,List<GenericValue>> protected final UtilCache<GenericPK,List<GenericValue>> protected EntityConfigUtil.DelegatorInfoprotected final Stringprotected DistributedCacheClearprotected final ModelGroupReaderprotected final ModelReaderstatic final Stringprotected final UtilCache<GenericEntity,GenericValue> protected SequenceUtilprotected SqlEscapeHelper -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedGenericDelegator(String delegatorName) Contructor is protected to enforce creation through the factory method. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAllCacheLinesByDummyPK(Collection<? extends GenericEntity> dummyPKs) voidclearAllCacheLinesByValue(Collection<? extends GenericValue> values) voidThis method is a shortcut to completely clear all entity engine caches.voidclearAllCaches(boolean distribute) voidclearCacheLine(String entityName, Map<String, ?> fields) Remove a CACHED Generic Entity (List) from the cache, either a PK, ByAnd, or AllvoidclearCacheLine(GenericPK primaryKey) Remove a CACHED Generic Entity from the cache by its primary key, does NOT check to see if the passed GenericPK is a complete primary key.voidclearCacheLine(GenericPK primaryKey, boolean distribute) voidclearCacheLine(GenericValue value) Remove a CACHED GenericValue from as many caches as it can.voidclearCacheLine(GenericValue value, boolean distribute) voidclearCacheLineFlexible(GenericEntity dummyPK) Remove a CACHED Generic Entity from the cache by its primary key.voidclearCacheLineFlexible(GenericEntity dummyPK, boolean distribute) intReturns the row count of the specified entity.intcountByAnd(String entityName, String fieldName, List<? extends EntityCondition> expressions, EntityFindOptions findOptions) Returns the count of the results that match all of the specified expressions (i.e.intcountByCondition(String entityName, String fieldName, EntityCondition entityCondition, EntityFindOptions findOptions) Returns the count of the results that match any of the specified expressions (ie: combined using OR).intcountByOr(String entityName, String fieldName, List<? extends EntityCondition> expressions, EntityFindOptions findOptions) Returns the count of the results that match any of the specified expressions (i.e.Creates a Entity in the form of a GenericValue and write it to the database.Creates a Entity in the form of a GenericValue and write it to the datasource.Creates a Entity in the form of a GenericValue and write it to the datasource.create(GenericValue value) Creates a Entity in the form of a GenericValue and write it to the datasource.create(GenericValue value, boolean doCacheClear) Creates a Entity in the form of a GenericValue and write it to the datasource.Finds all Generic entities of the given type.Finds all Generic entities of the given type, optionally sorted.findAllByPrimaryKeys(Collection<? extends GenericPK> primaryKeys) Find a number of Generic Value objects by their Primary Keys, all at once.findAllByPrimaryKeysCache(Collection<? extends GenericPK> primaryKeys) Find a number of Generic Value objects by their Primary Keys, all at once; this first looks in the local cache for each PK and if there then it puts it in the return list rather than putting it in the batch to send to a given helper.findAllCache(String entityName) Finds all Generic entities of the given type, looking first in the cache.findAllCache(String entityName, List<String> orderBy) Finds all Generic entities, looking first in the cache; uses orderBy for lookup, but only keys results on the entityName and fields.findByAnd(String entityName, List<? extends EntityCondition> expressions) Finds Generic Entity records by all of the specified expressions (ie: combined using AND).Finds Generic Entity records by all of the specified expressions (i.e.Finds Generic Entity records by all of the specified fields (ie: combined using AND).Finds Generic Entity records by all of the specified fields (i.e.Finds any entities matching the given criteria.findByAndCache(String entityName, Map<String, ?> fields) Finds Generic Entity records by all of the specified fields (i.e.Finds Generic Entity records by all of the specified fields (i.e.findByCondition(String entityName, EntityCondition entityCondition, Collection<String> fieldsToSelect, List<String> orderBy) Finds any GenericValues matching the given conditions.findByLike(String entityName, Map<String, ?> fields) findByOr(String entityName, List<? extends EntityCondition> expressions) Finds Generic Entity records by all of the specified expressions (i.e.Finds Generic Entity records by all of the specified expressions (i.e.Finds Generic Entity records by any of the specified fields (i.e.Finds Generic Entity records by all of the specified fields (i.e.findByPrimaryKey(String entityName, Map<String, ?> fields) Find a Generic Entity by its Primary Key.findByPrimaryKey(GenericPK primaryKey) Find a Generic Entity by its Primary Key.findByPrimaryKeyCache(String entityName, Map<String, ?> fields) Find a CACHED Generic Entity by its Primary Key.findByPrimaryKeyCache(GenericPK primaryKey) Find a cached Generic Entity by its Primary Key.findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) Find a Generic Entity by its Primary Key and only returns the values requested by the passed keys (names).findListIteratorByCondition(String entityName, EntityCondition entityCondition, Collection<String> fieldsToSelect, List<String> orderBy) Finds GenericValues by the given conditions.findListIteratorByCondition(String entityName, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions) Finds GenericValues by the given conditions.protected EntityConfigUtil.DelegatorInfoGets the name of the server configuration that corresponds to this delegator.getEntityFieldType(ModelEntity entity, String type) Gets a field type instance by name from the helper that corresponds to the specified entity.getEntityFieldTypeNames(ModelEntity entity) Gets field type names from the helper that corresponds to the specified entity.getEntityGroupName(String entityName) Gets the helper name that corresponds to this delegator and the specified entityName.getEntityHelper(String entityName) Gets the helper that corresponds to this delegator and the specified entityName.getEntityHelper(ModelEntity entity) Gets the helper that corresponds to this delegator and the specified entity.getEntityHelperName(String entityName) Gets the helper name that corresponds to this delegator and the specified entityName.getEntityHelperName(ModelEntity entity) Gets the helper name that corresponds to this delegator and the specified entity.getFieldNameSetsCopy(String entityName) Gets a Set of Sets of fieldNames used in the by and cache for the given entityName.getFromAllCache(String entityName) getFromAndCache(String entityName, Map<String, ?> fields) getFromAndCache(ModelEntity entity, Map<String, ?> fields) getFromPrimaryKeyCache(GenericPK primaryKey) static GenericDelegatorgetGenericDelegator(String delegatorName) Factory method for a GenericDelegator with the given name.getGroupHelperName(String groupName) Gets the helper name that corresponds to this delegator and the specified entityName.getModelEntitiesByGroup(String groupName) Gets a list of entity models that are in a group corresponding to the specified group name.getModelEntity(String entityName) Gets the instance of ModelEntity that corresponds to this delegator and the specified entityName.getModelEntityMapByGroup(String groupName) Gets a Map of entity name & entity model pairs that are in the named group.Gets the instance of ModelGroupReader that corresponds to this delegator.Gets the instance of ModelReader that corresponds to this delegator.getMultiRelation(GenericValue value, String relationNameOne, String relationNameTwo) Get the named Related Entity for the GenericValue from the persistent store across another Relation.getMultiRelation(GenericValue value, String relationNameOne, String relationNameTwo, List<String> orderBy) Get the named Related Entity for the GenericValue from the persistent store across another Relation.getNextSeqId(String seqName, boolean clusterMode) Get the next guaranteed unique seq id from the sequence with the given sequence name; if the named sequence doesn't exist, it will be created.getRelated(String relationName, Map<String, ?> byAndFields, List<String> orderBy, GenericValue value) Get the named Related Entity for the GenericValue from the persistent store.getRelated(String relationName, GenericValue value) Get the named Related Entity for the GenericValue from the persistent storegetRelatedByAnd(String relationName, Map<String, ?> byAndFields, GenericValue value) Get the named Related Entity for the GenericValue from the persistent store.getRelatedCache(String relationName, GenericValue value) Get the named Related Entity for the GenericValue from the persistent store, checking first in the cache to see if the desired value is there.getRelatedDummyPK(String relationName, Map<String, ?> byAndFields, GenericValue value) Get a dummy primary key for the named Related Entity for the GenericValue.getRelatedOne(String relationName, GenericValue value) Get related entity where relation is of type one, uses findByPrimaryKey.getRelatedOneCache(String relationName, GenericValue value) Get related entity where relation is of type one, uses findByPrimaryKey, checking first in the cache to see if the desired value is there.getRelatedOrderBy(String relationName, List<String> orderBy, GenericValue value) Get the named Related Entity for the GenericValue from the persistent store.voidIf you got an instance of GenericDelegator while the whole thing was locked, you need to make sure you call this once it becomes unlocked before you do anything.static booleanisLocked()static voidlock()Creates a Primary Key in the form of a GenericPK without persisting it.Creates a Entity in the form of a GenericValue without persisting it.makeValues(Document document) Parses the given XML document for entities.voidputAllInPrimaryKeyCache(List<? extends GenericValue> values) voidputInAllCache(String entityName, List<? extends GenericValue> values) voidputInAllCache(ModelEntity entity, List<? extends GenericValue> values) voidputInAndCache(String entityName, Map<String, ?> fields, List<? extends GenericValue> values) voidputInAndCache(ModelEntity entity, Map<String, ?> fields, List<? extends GenericValue> values) voidputInPrimaryKeyCache(GenericPK primaryKey, GenericValue value) readXmlDocument(URL url) Parses the given XML file for entities.voidrefresh(GenericValue value) Refresh the Entity for the GenericValue from the persistent store.voidrefresh(GenericValue value, boolean doCacheClear) Refresh the Entity for the GenericValue from the persistent store.voidRefreshes the ID sequencer clearing all cached bank values.intremoveAll(List<? extends GenericEntity> dummyPKs) Remove the Entities from the List from the persistent store.intremoveAll(List<? extends GenericEntity> dummyPKs, boolean doCacheClear) Remove the Entities from the List from the persistent store.intremoveByAnd(String entityName, Map<String, ?> fields) Removes/deletes Generic Entity records found by all of the specified fields (ie: combined using AND).intremoveByAnd(String entityName, Map<String, ?> fields, boolean doCacheClear) Removes/deletes Generic Entity records found by all of the specified fields (ie: combined using AND).intremoveByCondition(String entityName, EntityCondition whereCondition) Removes/deletes Generic Entity records found by matching the EntityCondition.intremoveByCondition(String entityName, EntityCondition whereCondition, boolean doCacheClear) Removes/deletes Generic Entity records found by matching the EntityCondition.intremoveByPrimaryKey(GenericPK primaryKey) Remove a Generic Entity corresponding to the primaryKey.intremoveByPrimaryKey(GenericPK primaryKey, boolean doCacheClear) Remove a Generic Entity corresponding to the primaryKey.static voidremoveGenericDelegator(String delegatorName) Removes any references to the delegator with the given name.intremoveRelated(String relationName, GenericValue value) Remove the named Related Entity for the GenericValue from the persistent store.intremoveRelated(String relationName, GenericValue value, boolean doCacheClear) Remove the named Related Entity for the GenericValue from the persistent store.intremoveValue(GenericValue value) Remove a Generic Value from the database.intremoveValue(GenericValue value, boolean doCacheClear) Remove a Generic Value from the database.voidsetSequencer(SequenceUtil sequencer) Allows you to pass a SequenceUtil class (possibly one that overrides the getNextSeqId method); if null is passed will effectively refresh the sequencer.intstore(GenericValue value) Store the Entity from the GenericValue to the persistent store.intstore(GenericValue value, boolean doCacheClear) Store the Entity from the GenericValue to the persistent store.intstoreAll(List<? extends GenericValue> values) Store the Entities from the List GenericValue instances to the persistent store.intstoreAll(List<? extends GenericValue> values, boolean doCacheClear) Store the Entities from the List GenericValue instances to the persistent store.transform(String entityName, EntityCondition entityCondition, List<String> orderBy, String lockField, Transformation transformation) Applies the given transformation to any entities matching the given condition.static voidunlock()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ofbiz.core.entity.DelegatorInterface
getNextSeqId
-
Field Details
-
module
-
modelGroupReader
-
modelReader
-
delegatorName
-
-
andCache
-
allCache
-
andCacheFieldSets
-
delegatorInfo
-
distributedCacheClear
-
sequencer
-
sqlEscapeHelper
-
-
Constructor Details
-
GenericDelegator
protected GenericDelegator() -
GenericDelegator
Contructor is protected to enforce creation through the factory method.- Parameters:
delegatorName- the name of the server configuration that corresponds to this delegator- Throws:
GenericEntityException
-
-
Method Details
-
getGenericDelegator
Factory method for a GenericDelegator with the given name.- Parameters:
delegatorName- the name of the server configuration that corresponds to this delegator- Returns:
- a non-null instance
- Throws:
RuntimeException- if the delegator could not be instantiated
-
removeGenericDelegator
Removes any references to the delegator with the given name.- Parameters:
delegatorName- the name of the server configuration that corresponds to this delegator
-
lock
public static void lock() -
unlock
public static void unlock() -
isLocked
public static boolean isLocked() -
initialiseAndCheckDatabase
public void initialiseAndCheckDatabase()If you got an instance of GenericDelegator while the whole thing was locked, you need to make sure you call this once it becomes unlocked before you do anything. -
getDelegatorName
Gets the name of the server configuration that corresponds to this delegator.- Specified by:
getDelegatorNamein interfaceDelegatorInterface- Returns:
- server configuration name
-
getDelegatorInfo
-
getModelReader
Gets the instance of ModelReader that corresponds to this delegator.- Specified by:
getModelReaderin interfaceDelegatorInterface- Returns:
- ModelReader that corresponds to this delegator
-
getModelGroupReader
Gets the instance of ModelGroupReader that corresponds to this delegator.- Specified by:
getModelGroupReaderin interfaceDelegatorInterface- Returns:
- ModelGroupReader that corresponds to this delegator
-
getModelEntity
Gets the instance of ModelEntity that corresponds to this delegator and the specified entityName.- Specified by:
getModelEntityin interfaceDelegatorInterface- Parameters:
entityName- The name of the entity to get- Returns:
- ModelEntity that corresponds to this delegator and the specified entityName
-
getEntityGroupName
Gets the helper name that corresponds to this delegator and the specified entityName.- Specified by:
getEntityGroupNamein interfaceDelegatorInterface- Parameters:
entityName- The name of the entity to get the helper for- Returns:
- String with the helper name that corresponds to this delegator and the specified entityName
-
getModelEntitiesByGroup
Gets a list of entity models that are in a group corresponding to the specified group name.- Specified by:
getModelEntitiesByGroupin interfaceDelegatorInterface- Parameters:
groupName- The name of the group- Returns:
- List of ModelEntity instances
-
getModelEntityMapByGroup
Gets a Map of entity name & entity model pairs that are in the named group.- Specified by:
getModelEntityMapByGroupin interfaceDelegatorInterface- Parameters:
groupName- The name of the group- Returns:
- Map of entityName String keys and ModelEntity instance values
-
getGroupHelperName
Gets the helper name that corresponds to this delegator and the specified entityName.- Specified by:
getGroupHelperNamein interfaceDelegatorInterface- Parameters:
groupName- The name of the group to get the helper name for- Returns:
- String with the helper name that corresponds to this delegator and the specified entityName
-
getEntityHelperName
Gets the helper name that corresponds to this delegator and the specified entityName.- Specified by:
getEntityHelperNamein interfaceDelegatorInterface- Parameters:
entityName- The name of the entity to get the helper name for- Returns:
- String with the helper name that corresponds to this delegator and the specified entityName
-
getEntityHelperName
Gets the helper name that corresponds to this delegator and the specified entity.- Specified by:
getEntityHelperNamein interfaceDelegatorInterface- Parameters:
entity- the entity for which to get the helper (can be null)- Returns:
- String with the helper name that corresponds to this delegator and the specified entity
-
getEntityHelper
Gets the helper that corresponds to this delegator and the specified entityName.- Specified by:
getEntityHelperin interfaceDelegatorInterface- Parameters:
entityName- The name of the entity to get the helper for- Returns:
- GenericHelper that corresponds to this delegator and the specified entityName
- Throws:
GenericEntityException
-
getEntityHelper
Gets the helper that corresponds to this delegator and the specified entity.- Specified by:
getEntityHelperin interfaceDelegatorInterface- Parameters:
entity- The entity for which to get the helper (required)- Returns:
- GenericHelper that corresponds to this delegator and the specified entity
- Throws:
GenericEntityException
-
getEntityFieldType
public ModelFieldType getEntityFieldType(ModelEntity entity, String type) throws GenericEntityException Gets a field type instance by name from the helper that corresponds to the specified entity.- Specified by:
getEntityFieldTypein interfaceDelegatorInterface- Parameters:
entity- The entitytype- The name of the type- Returns:
- ModelFieldType instance for the named type from the helper that corresponds to the specified entity
- Throws:
GenericEntityException
-
getEntityFieldTypeNames
Gets field type names from the helper that corresponds to the specified entity.- Specified by:
getEntityFieldTypeNamesin interfaceDelegatorInterface- Parameters:
entity- The entity- Returns:
- Collection of field type names from the helper that corresponds to the specified entity
- Throws:
GenericEntityException
-
makeValue
Creates a Entity in the form of a GenericValue without persisting it.- Specified by:
makeValuein interfaceDelegatorInterface- Parameters:
entityName- the type of entity to create (must exist in the model)fields- the entity fields and their values (can be null)- Returns:
- the created value
-
makePK
Creates a Primary Key in the form of a GenericPK without persisting it.- Specified by:
makePKin interfaceDelegatorInterface- Parameters:
entityName- the type of entity for which to create a PK (must exist in the model)fields- the primary key fields and their values (can be null)- Returns:
- the created PK
-
create
Creates a Entity in the form of a GenericValue and write it to the database.- Specified by:
createin interfaceDelegatorInterface- Parameters:
entityName- the type of entity to create (if null, this method does nothing)fields- the field values to use (if null, this method does nothing)- Returns:
- the created instance
- Throws:
GenericEntityException
-
create
Creates a Entity in the form of a GenericValue and write it to the datasource.- Specified by:
createin interfaceDelegatorInterface- Parameters:
value- The GenericValue to create a value in the datasource from- Returns:
- GenericValue instance containing the new instance
- Throws:
GenericEntityException
-
create
Creates a Entity in the form of a GenericValue and write it to the datasource.- Specified by:
createin interfaceDelegatorInterface- Parameters:
value- The GenericValue from which to create a value in the datasource (required)doCacheClear- whether to automatically clear cache entries related to this operation- Returns:
- GenericValue instance containing the new instance
- Throws:
GenericEntityException
-
create
Creates a Entity in the form of a GenericValue and write it to the datasource.- Specified by:
createin interfaceDelegatorInterface- Parameters:
primaryKey- The GenericPK to create a value in the datasource from- Returns:
- GenericValue instance containing the new instance
- Throws:
GenericEntityException
-
create
public GenericValue create(GenericPK primaryKey, boolean doCacheClear) throws GenericEntityException Creates a Entity in the form of a GenericValue and write it to the datasource.- Specified by:
createin interfaceDelegatorInterface- Parameters:
primaryKey- the PK from which to create a value in the datasource (required)doCacheClear- whether to clear related cache entries for this primaryKey to be created- Returns:
- GenericValue instance containing the new instance
- Throws:
GenericEntityException
-
findByPrimaryKey
Find a Generic Entity by its Primary Key.- Specified by:
findByPrimaryKeyin interfaceDelegatorInterface- Parameters:
primaryKey- The primary key to find by.- Returns:
- The GenericValue corresponding to the primaryKey
- Throws:
GenericEntityException
-
findByPrimaryKeyCache
Find a cached Generic Entity by its Primary Key.- Specified by:
findByPrimaryKeyCachein interfaceDelegatorInterface- Parameters:
primaryKey- The primary key to find by.- Returns:
- The GenericValue corresponding to the primaryKey
- Throws:
GenericEntityException
-
findByPrimaryKey
public GenericValue findByPrimaryKey(String entityName, Map<String, ?> fields) throws GenericEntityExceptionFind a Generic Entity by its Primary Key.- Specified by:
findByPrimaryKeyin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging values- Returns:
- The GenericValue corresponding to the primaryKey
- Throws:
GenericEntityException
-
findByPrimaryKeyCache
public GenericValue findByPrimaryKeyCache(String entityName, Map<String, ?> fields) throws GenericEntityExceptionFind a CACHED Generic Entity by its Primary Key.- Specified by:
findByPrimaryKeyCachein interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging values- Returns:
- The GenericValue corresponding to the primaryKey
- Throws:
GenericEntityException
-
findByPrimaryKeyPartial
public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) throws GenericEntityException Find a Generic Entity by its Primary Key and only returns the values requested by the passed keys (names).- Specified by:
findByPrimaryKeyPartialin interfaceDelegatorInterface- Parameters:
primaryKey- The primary key to find by.keys- The keys, or names, of the values to retrieve; only these values will be retrieved- Returns:
- The GenericValue corresponding to the primaryKey
- Throws:
GenericEntityException
-
findAllByPrimaryKeys
public List<GenericValue> findAllByPrimaryKeys(Collection<? extends GenericPK> primaryKeys) throws GenericEntityException Find a number of Generic Value objects by their Primary Keys, all at once.- Specified by:
findAllByPrimaryKeysin interfaceDelegatorInterface- Parameters:
primaryKeys- A Collection of primary keys to find by.- Returns:
- List of GenericValue objects corresponding to the passed primaryKey objects
- Throws:
GenericEntityException
-
findAllByPrimaryKeysCache
public List<GenericValue> findAllByPrimaryKeysCache(Collection<? extends GenericPK> primaryKeys) throws GenericEntityException Find a number of Generic Value objects by their Primary Keys, all at once; this first looks in the local cache for each PK and if there then it puts it in the return list rather than putting it in the batch to send to a given helper.- Specified by:
findAllByPrimaryKeysCachein interfaceDelegatorInterface- Parameters:
primaryKeys- A Collection of primary keys to find by.- Returns:
- List of GenericValue objects corresponding to the passed primaryKey objects
- Throws:
GenericEntityException
-
findAll
Finds all Generic entities of the given type.- Specified by:
findAllin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML file- Returns:
- all entities of the given type
- Throws:
GenericEntityException
-
findAll
public List<GenericValue> findAll(String entityName, List<String> orderBy) throws GenericEntityException Finds all Generic entities of the given type, optionally sorted.- Specified by:
findAllin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML fileorderBy- the entity fields by which to order the query; optionally add " ASC" for ascending or " DESC" for descending to each field name- Returns:
- List containing all Generic entities
- Throws:
GenericEntityException
-
findAllCache
Finds all Generic entities of the given type, looking first in the cache.- Specified by:
findAllCachein interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML file- Returns:
- List containing all Generic entities
- Throws:
GenericEntityException
-
findAllCache
public List<GenericValue> findAllCache(String entityName, List<String> orderBy) throws GenericEntityException Finds all Generic entities, looking first in the cache; uses orderBy for lookup, but only keys results on the entityName and fields.- Specified by:
findAllCachein interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML fileorderBy- The fields of the named entity by which to order the query; optionally add " ASC" for ascending or " DESC" for descending- Returns:
- all Generic entities
- Throws:
GenericEntityException
-
findByAnd
public List<GenericValue> findByAnd(String entityName, Map<String, ?> fields) throws GenericEntityExceptionFinds Generic Entity records by all of the specified fields (ie: combined using AND).- Specified by:
findByAndin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging values- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByOr
public List<GenericValue> findByOr(String entityName, Map<String, ?> fields) throws GenericEntityExceptionFinds Generic Entity records by any of the specified fields (i.e. combined using OR).- Specified by:
findByOrin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging values- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByAnd
public List<GenericValue> findByAnd(String entityName, Map<String, ?> fields, List<String> orderBy) throws GenericEntityExceptionFinds Generic Entity records by all of the specified fields (i.e. combined using AND).- Specified by:
findByAndin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- the names and values of the fields by which to query (can be null)orderBy- The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByAnd
public List<GenericValue> findByAnd(ModelEntity modelEntity, Map<String, ?> fields, List<String> orderBy) throws GenericEntityExceptionFinds any entities matching the given criteria.- Specified by:
findByAndin interfaceDelegatorInterface- Parameters:
modelEntity- the type of entity to find (required)fields- the names and values of the fields by which to query (can be null)orderBy- the names of fields by which to sort the results (can be null)- Returns:
- any matching entities
- Throws:
GenericEntityException
-
findByOr
public List<GenericValue> findByOr(String entityName, Map<String, ?> fields, List<String> orderBy) throws GenericEntityExceptionFinds Generic Entity records by all of the specified fields (i.e. combined using OR).- Specified by:
findByOrin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging valuesorderBy- The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByAndCache
public List<GenericValue> findByAndCache(String entityName, Map<String, ?> fields) throws GenericEntityExceptionFinds Generic Entity records by all of the specified fields (i.e. combined using AND), looking first in the cache; uses orderBy for lookup, but only keys results on the entityName and fields.- Specified by:
findByAndCachein interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging values- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByAndCache
public List<GenericValue> findByAndCache(String entityName, Map<String, ?> fields, List<String> orderBy) throws GenericEntityExceptionFinds Generic Entity records by all of the specified fields (i.e. combined using AND), looking first in the cache; uses orderBy for lookup, but only keys results on the entityName and fields.- Specified by:
findByAndCachein interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging valuesorderBy- The fields of the named entity to order the query by; optionally add " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByAnd
public List<GenericValue> findByAnd(String entityName, List<? extends EntityCondition> expressions) throws GenericEntityException Finds Generic Entity records by all of the specified expressions (ie: combined using AND).- Specified by:
findByAndin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML fileexpressions- The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByAnd
public List<GenericValue> findByAnd(String entityName, List<? extends EntityCondition> expressions, List<String> orderBy) throws GenericEntityException Finds Generic Entity records by all of the specified expressions (i.e. combined using AND).- Specified by:
findByAndin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML fileexpressions- The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare toorderBy- The fields of the named entity to order the query by; optionally add " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByOr
public List<GenericValue> findByOr(String entityName, List<? extends EntityCondition> expressions) throws GenericEntityException Finds Generic Entity records by all of the specified expressions (i.e. combined using OR).- Specified by:
findByOrin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML fileexpressions- The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByOr
public List<GenericValue> findByOr(String entityName, List<? extends EntityCondition> expressions, List<String> orderBy) throws GenericEntityException Finds Generic Entity records by all of the specified expressions (i.e. combined using OR).- Specified by:
findByOrin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML fileexpressions- The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare toorderBy- The fields of the named entity to order the query by; optionally add " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances that match the query
- Throws:
GenericEntityException
-
findByLike
public List<GenericValue> findByLike(String entityName, Map<String, ?> fields) throws GenericEntityException- Specified by:
findByLikein interfaceDelegatorInterface- Throws:
GenericEntityException
-
findByLike
public List<GenericValue> findByLike(String entityName, Map<String, ?> fields, List<String> orderBy) throws GenericEntityException- Specified by:
findByLikein interfaceDelegatorInterface- Throws:
GenericEntityException
-
findByCondition
public List<GenericValue> findByCondition(String entityName, EntityCondition entityCondition, Collection<String> fieldsToSelect, List<String> orderBy) throws GenericEntityException Finds any GenericValues matching the given conditions.- Specified by:
findByConditionin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity model XML fileentityCondition- The EntityCondition object that specifies how to constrain this queryfieldsToSelect- The fields of the named entity to get from the database; if empty or null all fields will be retreivedorderBy- The fields of the named entity by which to order the query; optionally add " ASC" for ascending or " DESC" for descending- Returns:
- any matching values
- Throws:
GenericEntityException
-
countByAnd
public int countByAnd(String entityName, String fieldName, List<? extends EntityCondition> expressions, EntityFindOptions findOptions) throws GenericEntityException Returns the count of the results that match all of the specified expressions (i.e. combined using AND).- Specified by:
countByAndin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity model XML filefieldName- The field of the named entity to count, if null this is equivalent to count(*)expressions- The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare tofindOptions- An instance of EntityFindOptions that specifies advanced query options. The only option that is used is distinct, in which case a select (distinct fieldname) is issued.If you issue a distinct without a fieldName, it will be ignored because
select count (distinct *)makes no sense- Returns:
- the number of rows that match the query
- Throws:
GenericEntityException
-
countByOr
public int countByOr(String entityName, String fieldName, List<? extends EntityCondition> expressions, EntityFindOptions findOptions) throws GenericEntityException Returns the count of the results that match any of the specified expressions (i.e. combined using OR).- Specified by:
countByOrin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity model XML filefieldName- The field of the named entity to count, if null this is equivalent to count(*)expressions- The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare tofindOptions- An instance of EntityFindOptions that specifies advanced query options. The only option that is used is distinct, in which case aselect (distinct fieldname)is issued.If you issue a distinct without a fieldName, it will be ignored because
select count (distinct *)makes no sense- Returns:
- the number of rows that match the query
- Throws:
GenericEntityException
-
countByCondition
public int countByCondition(String entityName, String fieldName, EntityCondition entityCondition, EntityFindOptions findOptions) throws GenericEntityException Returns the count of the results that match any of the specified expressions (ie: combined using OR).- Specified by:
countByConditionin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity model XML filefieldName- The field of the named entity to count, if null this is equivalent to count(*)entityCondition- The EntityCondition object that specifies how to constrain this query The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare tofindOptions- An instance of EntityFindOptions that specifies advanced query options. The only option that is used is distinct, in which case a select (distinct fieldname) is issued.If you issue a distinct without a fieldName, it will be ignored as
select count (distinct *)makes no sense- Returns:
- the number of rows that match the query
- Throws:
GenericEntityException
-
countAll
Returns the row count of the specified entity.- Specified by:
countAllin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity model XML file- Returns:
- the number of rows in the table
- Throws:
GenericEntityException
-
findListIteratorByCondition
public EntityListIterator findListIteratorByCondition(String entityName, EntityCondition entityCondition, Collection<String> fieldsToSelect, List<String> orderBy) throws GenericEntityException Finds GenericValues by the given conditions.- Specified by:
findListIteratorByConditionin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity model XML fileentityCondition- The EntityCondition object that specifies how to constrain this query before any groupings are done (if this is a view entity with group-by aliases)fieldsToSelect- The fields of the named entity to get from the database; if empty or null all fields will be retreivedorderBy- The fields of the named entity to order the query by; optionally add " ASC" for ascending or " DESC" for descending- Returns:
- EntityListIterator representing the result of the query: NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE DONE WITH IT, AND DON'T LEAVE IT OPEN TOO LONG BECAUSE IT WILL MAINTAIN A DATABASE CONNECTION.
- Throws:
GenericEntityException
-
findListIteratorByCondition
public EntityListIterator findListIteratorByCondition(String entityName, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions) throws GenericEntityException Finds GenericValues by the given conditions.- Specified by:
findListIteratorByConditionin interfaceDelegatorInterface- Parameters:
entityName- The ModelEntity of the Entity as defined in the entity XML filewhereEntityCondition- The EntityCondition object that specifies how to constrain this query before any groupings are done (if this is a view entity with group-by aliases)havingEntityCondition- The EntityCondition object that specifies how to constrain this query after any groupings are done (if this is a view entity with group-by aliases)fieldsToSelect- The fields of the named entity to get from the database; if empty or null all fields will be retreivedorderBy- The fields of the named entity to order the query by; optionally add " ASC" for ascending or " DESC" for descendingfindOptions- An instance of EntityFindOptions that specifies advanced query options. See the EntityFindOptions JavaDoc for more details.- Returns:
- EntityListIterator representing the result of the query: NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE DONE WITH IT, AND DON'T LEAVE IT OPEN TOO LONG BECAUSE IT WILL MAINTAIN A DATABASE CONNECTION.
- Throws:
GenericEntityException- See Also:
-
removeByPrimaryKey
Remove a Generic Entity corresponding to the primaryKey.- Specified by:
removeByPrimaryKeyin interfaceDelegatorInterface- Parameters:
primaryKey- The primary key of the entity to remove.- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeByPrimaryKey
public int removeByPrimaryKey(GenericPK primaryKey, boolean doCacheClear) throws GenericEntityException Remove a Generic Entity corresponding to the primaryKey.- Specified by:
removeByPrimaryKeyin interfaceDelegatorInterface- Parameters:
primaryKey- The primary key of the entity to remove.doCacheClear- boolean that specifies whether to clear cache entries for this primaryKey to be removed- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeValue
Remove a Generic Value from the database.- Specified by:
removeValuein interfaceDelegatorInterface- Parameters:
value- The GenericValue object of the entity to remove.- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeValue
Remove a Generic Value from the database.- Specified by:
removeValuein interfaceDelegatorInterface- Parameters:
value- The GenericValue object of the entity to remove.doCacheClear- boolean that specifies whether to clear cache entries for this value to be removed- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeByAnd
Removes/deletes Generic Entity records found by all of the specified fields (ie: combined using AND).- Specified by:
removeByAndin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging values- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeByAnd
public int removeByAnd(String entityName, Map<String, ?> fields, boolean doCacheClear) throws GenericEntityExceptionRemoves/deletes Generic Entity records found by all of the specified fields (ie: combined using AND).- Specified by:
removeByAndin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging valuesdoCacheClear- boolean that specifies whether to clear cache entries for this value to be removed- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeByCondition
public int removeByCondition(String entityName, EntityCondition whereCondition) throws GenericEntityException Removes/deletes Generic Entity records found by matching the EntityCondition.- Specified by:
removeByConditionin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filewhereCondition- The EntityCondition object that specifies how to constrain this query- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeByCondition
public int removeByCondition(String entityName, EntityCondition whereCondition, boolean doCacheClear) throws GenericEntityException Removes/deletes Generic Entity records found by matching the EntityCondition.- Specified by:
removeByConditionin interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filewhereCondition- The EntityCondition object that specifies how to constrain this querydoCacheClear- boolean that specifies whether to clear cache entries for this value to be removed- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
getMultiRelation
public List<GenericValue> getMultiRelation(GenericValue value, String relationNameOne, String relationNameTwo, List<String> orderBy) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store across another Relation. Helps to get related Values in a multi-to-multi relationship.- Specified by:
getMultiRelationin interfaceDelegatorInterface- Parameters:
relationNameOne- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file, for first relationrelationNameTwo- String containing the relation name for second relationvalue- GenericValue instance containing the entityorderBy- The fields of the named entity to order the query by; may be null; optionally add a " ASC" for ascending or " DESC" for descending- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getMultiRelation
public List<GenericValue> getMultiRelation(GenericValue value, String relationNameOne, String relationNameTwo) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store across another Relation. Helps to get related Values in a multi-to-multi relationship.- Specified by:
getMultiRelationin interfaceDelegatorInterface- Parameters:
relationNameOne- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition file, for first relationrelationNameTwo- String containing the relation name for second relationvalue- GenericValue instance containing the entity- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelated
public List<GenericValue> getRelated(String relationName, GenericValue value) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store- Specified by:
getRelatedin interfaceDelegatorInterface- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filevalue- GenericValue instance containing the entity- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedByAnd
public List<GenericValue> getRelatedByAnd(String relationName, Map<String, ?> byAndFields, GenericValue value) throws GenericEntityExceptionGet the named Related Entity for the GenericValue from the persistent store.- Specified by:
getRelatedByAndin interfaceDelegatorInterface- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filebyAndFields- the fields that must equal in order to keep; may be nullvalue- GenericValue instance containing the entity- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedOrderBy
public List<GenericValue> getRelatedOrderBy(String relationName, List<String> orderBy, GenericValue value) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store.- Specified by:
getRelatedOrderByin interfaceDelegatorInterface- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition fileorderBy- The fields of the named entity to order the query by; may be null; optionally add a " ASC" for ascending or " DESC" for descendingvalue- GenericValue instance containing the entity- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelated
public List<GenericValue> getRelated(String relationName, Map<String, ?> byAndFields, List<String> orderBy, GenericValue value) throws GenericEntityExceptionGet the named Related Entity for the GenericValue from the persistent store.- Specified by:
getRelatedin interfaceDelegatorInterface- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filebyAndFields- the fields that must equal in order to keep; may be nullorderBy- The fields of the named entity to order the query by; may be null; optionally add a " ASC" for ascending or " DESC" for descendingvalue- GenericValue instance containing the entity- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedDummyPK
public GenericPK getRelatedDummyPK(String relationName, Map<String, ?> byAndFields, GenericValue value) throws GenericEntityExceptionGet a dummy primary key for the named Related Entity for the GenericValue.- Specified by:
getRelatedDummyPKin interfaceDelegatorInterface- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filebyAndFields- the fields that must equal in order to keep; may be nullvalue- GenericValue instance containing the entity- Returns:
- GenericPK containing a possibly incomplete PrimaryKey object representing the related entity or entities
- Throws:
GenericEntityException
-
getRelatedCache
public List<GenericValue> getRelatedCache(String relationName, GenericValue value) throws GenericEntityException Get the named Related Entity for the GenericValue from the persistent store, checking first in the cache to see if the desired value is there.- Specified by:
getRelatedCachein interfaceDelegatorInterface- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filevalue- GenericValue instance containing the entity- Returns:
- List of GenericValue instances as specified in the relation definition
- Throws:
GenericEntityException
-
getRelatedOne
public GenericValue getRelatedOne(String relationName, GenericValue value) throws GenericEntityException Get related entity where relation is of type one, uses findByPrimaryKey.- Specified by:
getRelatedOnein interfaceDelegatorInterface- Parameters:
relationName- the name of the relation to get (required)value- the value whose relation to get (required)- Throws:
IllegalArgumentException- if the list found has more than one itemGenericEntityException
-
getRelatedOneCache
public GenericValue getRelatedOneCache(String relationName, GenericValue value) throws GenericEntityException Get related entity where relation is of type one, uses findByPrimaryKey, checking first in the cache to see if the desired value is there.- Specified by:
getRelatedOneCachein interfaceDelegatorInterface- Parameters:
relationName- the name of the relation to get (required)value- the value whose relation to get (required)- Throws:
IllegalArgumentException- if the list found has more than one itemGenericEntityException
-
removeRelated
Remove the named Related Entity for the GenericValue from the persistent store.- Specified by:
removeRelatedin interfaceDelegatorInterface- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filevalue- GenericValue instance containing the entity- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeRelated
public int removeRelated(String relationName, GenericValue value, boolean doCacheClear) throws GenericEntityException Remove the named Related Entity for the GenericValue from the persistent store.- Specified by:
removeRelatedin interfaceDelegatorInterface- Parameters:
relationName- String containing the relation name which is the combination of relation.title and relation.rel-entity-name as specified in the entity XML definition filevalue- GenericValue instance containing the entitydoCacheClear- boolean that specifies whether to clear cache entries for this value to be removed- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
refresh
Refresh the Entity for the GenericValue from the persistent store.- Specified by:
refreshin interfaceDelegatorInterface- Parameters:
value- GenericValue instance containing the entity to refresh- Throws:
GenericEntityException
-
refresh
Refresh the Entity for the GenericValue from the persistent store.- Specified by:
refreshin interfaceDelegatorInterface- Parameters:
value- GenericValue instance containing the entity to refreshdoCacheClear- whether to automatically clear cache entries related to this operation- Throws:
GenericEntityException
-
store
Store the Entity from the GenericValue to the persistent store.- Specified by:
storein interfaceDelegatorInterface- Parameters:
value- GenericValue instance containing the entity- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
store
Store the Entity from the GenericValue to the persistent store.- Specified by:
storein interfaceDelegatorInterface- Parameters:
value- GenericValue instance containing the entitydoCacheClear- whether to automatically clear cache entries related to this operation- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
storeAll
Store the Entities from the List GenericValue instances to the persistent store.
This is different than the normal store method in that the store method only does an update, while the storeAll method checks to see if each entity exists, then either does an insert or an update as appropriate.
These updates all happen in one transaction, so they will either all succeed or all fail, if the data source supports transactions. This is just like to othersToStore feature of the GenericEntity on a create or store.- Specified by:
storeAllin interfaceDelegatorInterface- Parameters:
values- List of GenericValue instances containing the entities to store- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
storeAll
public int storeAll(List<? extends GenericValue> values, boolean doCacheClear) throws GenericEntityException Store the Entities from the List GenericValue instances to the persistent store.
This is different than the normal store method in that the store method only does an update, while the storeAll method checks to see if each entity exists, then either does an insert or an update as appropriate.
These updates all happen in one transaction, so they will either all succeed or all fail, if the data source supports transactions. This is just like to othersToStore feature of the GenericEntity on a create or store.- Specified by:
storeAllin interfaceDelegatorInterface- Parameters:
values- List of GenericValue instances containing the entities to storedoCacheClear- whether to automatically clear cache entries related to this operation- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeAll
Remove the Entities from the List from the persistent store.
The List contains GenericEntity objects, can be either GenericPK or GenericValue.
If a certain entity contains a complete primary key, the entity in the datasource corresponding to that primary key will be removed, this is like a removeByPrimary Key.
On the other hand, if a certain entity is an incomplete or non primary key, if will behave like the removeByAnd method.
These updates all happen in one transaction, so they will either all succeed or all fail, if the data source supports transactions.- Specified by:
removeAllin interfaceDelegatorInterface- Parameters:
dummyPKs- Collection of GenericEntity instances containing the entities or by and fields to remove- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
removeAll
public int removeAll(List<? extends GenericEntity> dummyPKs, boolean doCacheClear) throws GenericEntityException Remove the Entities from the List from the persistent store.
The List contains GenericEntity objects, can be either GenericPK or GenericValue.
If a certain entity contains a complete primary key, the entity in the datasource corresponding to that primary key will be removed, this is like a removeByPrimary Key.
On the other hand, if a certain entity is an incomplete or non primary key, if will behave like the removeByAnd method.
These updates all happen in one transaction, so they will either all succeed or all fail, if the data source supports transactions.- Specified by:
removeAllin interfaceDelegatorInterface- Parameters:
dummyPKs- Collection of GenericEntity instances containing the entities or by and fields to removedoCacheClear- whether to automatically clear cache entries related to this operation- Returns:
- int representing number of rows affected by this operation
- Throws:
GenericEntityException
-
clearAllCaches
public void clearAllCaches()This method is a shortcut to completely clear all entity engine caches. For performance reasons this should not be called very often.- Specified by:
clearAllCachesin interfaceDelegatorInterface
-
clearAllCaches
public void clearAllCaches(boolean distribute) - Specified by:
clearAllCachesin interfaceDelegatorInterface
-
clearCacheLine
Remove a CACHED Generic Entity (List) from the cache, either a PK, ByAnd, or All- Specified by:
clearCacheLinein interfaceDelegatorInterface- Parameters:
entityName- The Name of the Entity as defined in the entity XML filefields- The fields of the named entity to query by with their corresponging values
-
clearCacheLineFlexible
Remove a CACHED Generic Entity from the cache by its primary key. Checks whether the passed GenericPK is a complete primary key; if it is, then the cache line will be removed from the primaryKeyCache; if it is NOT a complete primary key it will remove the cache line from the andCache. If the fields map is empty, then the allCache for the entity will be cleared.- Specified by:
clearCacheLineFlexiblein interfaceDelegatorInterface- Parameters:
dummyPK- The dummy primary key to clear by.
-
clearCacheLineFlexible
- Specified by:
clearCacheLineFlexiblein interfaceDelegatorInterface
-
clearCacheLine
Remove a CACHED Generic Entity from the cache by its primary key, does NOT check to see if the passed GenericPK is a complete primary key. Also tries to clear the corresponding all cache entry.- Specified by:
clearCacheLinein interfaceDelegatorInterface- Parameters:
primaryKey- The primary key to clear by.
-
clearCacheLine
- Specified by:
clearCacheLinein interfaceDelegatorInterface
-
clearCacheLine
Remove a CACHED GenericValue from as many caches as it can. Automatically tries to remove entries from the all cache, the by primary key cache, and the "by and" cache. This is the ONLY method that tries to clear automatically from the by and cache.- Specified by:
clearCacheLinein interfaceDelegatorInterface- Parameters:
value- The primary key to clear by.
-
clearCacheLine
- Specified by:
clearCacheLinein interfaceDelegatorInterface
-
getFieldNameSetsCopy
Gets a Set of Sets of fieldNames used in the by and cache for the given entityName.- Specified by:
getFieldNameSetsCopyin interfaceDelegatorInterface- Parameters:
entityName- the entity for which to get the field names (can be null)- Returns:
- null if the field name is null or simply unknown
-
clearAllCacheLinesByDummyPK
- Specified by:
clearAllCacheLinesByDummyPKin interfaceDelegatorInterface
-
clearAllCacheLinesByValue
- Specified by:
clearAllCacheLinesByValuein interfaceDelegatorInterface
-
getFromPrimaryKeyCache
- Specified by:
getFromPrimaryKeyCachein interfaceDelegatorInterface
-
getFromAllCache
- Specified by:
getFromAllCachein interfaceDelegatorInterface
-
getFromAndCache
- Specified by:
getFromAndCachein interfaceDelegatorInterface
-
getFromAndCache
- Specified by:
getFromAndCachein interfaceDelegatorInterface
-
putInPrimaryKeyCache
- Specified by:
putInPrimaryKeyCachein interfaceDelegatorInterface
-
putAllInPrimaryKeyCache
- Specified by:
putAllInPrimaryKeyCachein interfaceDelegatorInterface
-
putInAllCache
- Specified by:
putInAllCachein interfaceDelegatorInterface
-
putInAllCache
- Specified by:
putInAllCachein interfaceDelegatorInterface
-
putInAndCache
public void putInAndCache(String entityName, Map<String, ?> fields, List<? extends GenericValue> values) - Specified by:
putInAndCachein interfaceDelegatorInterface
-
putInAndCache
public void putInAndCache(ModelEntity entity, Map<String, ?> fields, List<? extends GenericValue> values) - Specified by:
putInAndCachein interfaceDelegatorInterface
-
readXmlDocument
public List<GenericValue> readXmlDocument(URL url) throws SAXException, ParserConfigurationException, IOException Parses the given XML file for entities. Does not insert them into the database.- Parameters:
url- the URL of the XML file (can be null)- Returns:
- null if a null URL was given, otherwise the parsed entities
- Throws:
SAXExceptionParserConfigurationExceptionIOException
-
makeValues
Parses the given XML document for entities. Does not insert them into the database.- Parameters:
document- the document to parse (can be null)- Returns:
- null if a null document was given, otherwise the parsed entities
-
makePK
-
makeValue
-
getNextSeqId
Description copied from interface:DelegatorInterfaceGet the next guaranteed unique seq id from the sequence with the given sequence name; if the named sequence doesn't exist, it will be created.If the instance should be running in cluster mode then it will try a SELECT FOR UPDATE approach to retrieving the next bank of sequence ids, to avoid potential collisions with other nodes.
If not in cluster mode, this is not required, and the existing JVM synchronization locking is enough.
It will be in clusterMode if true is passed as a parameter, or if
EntityConfigUtil.DelegatorInfo.useDistributedCacheClearis enabled- Specified by:
getNextSeqIdin interfaceDelegatorInterface- Parameters:
seqName- The name of the sequence to get the next seq id fromclusterMode- Is this a node in a clustered instance or not- Returns:
- Long with the next seq id for the given sequence name
-
setSequencer
Allows you to pass a SequenceUtil class (possibly one that overrides the getNextSeqId method); if null is passed will effectively refresh the sequencer.- Specified by:
setSequencerin interfaceDelegatorInterface- Parameters:
sequencer- the sequencer to set
-
refreshSequencer
public void refreshSequencer()Refreshes the ID sequencer clearing all cached bank values.- Specified by:
refreshSequencerin interfaceDelegatorInterface
-
getPrimaryKeyCache
- Specified by:
getPrimaryKeyCachein interfaceDelegatorInterface
-
getAndCache
- Specified by:
getAndCachein interfaceDelegatorInterface
-
getAllCache
- Specified by:
getAllCachein interfaceDelegatorInterface
-
transform
public List<GenericValue> transform(String entityName, EntityCondition entityCondition, List<String> orderBy, String lockField, Transformation transformation) throws GenericEntityException Description copied from interface:DelegatorInterfaceApplies the given transformation to any entities matching the given condition.- Specified by:
transformin interfaceDelegatorInterface- Parameters:
entityName- the type of entity to transform (required)entityCondition- the condition that selects the entities to transform (null means transform all)orderBy- the order in which the entities should be selected for updating (null means no ordering)lockField- the entity field to use for optimistic locking; the value of this field will be read between the SELECT and the UPDATE to determine whether another process has updated one of the target records in the meantime; if so, the transformation will be reapplied and another UPDATE attemptedtransformation- the transformation to apply (required)- Returns:
- the transformed entities in the order they were selected (never null)
- Throws:
GenericEntityException
-
getSqlEscapeHelper
- Specified by:
getSqlEscapeHelperin interfaceDelegatorInterface
-