Class GenericHelperDAO
java.lang.Object
org.apache.ofbiz.entity.datasource.GenericHelperDAO
- All Implemented Interfaces:
GenericHelper
Generic Entity Helper Class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkDataSource
(Map<String, ModelEntity> modelEntities, List<String> messages, boolean addMissing) Check the datasource to make sure the entity definitions are correct, optionally adding missing entities or fields on the servercreate
(GenericValue value) Creates a Entity in the form of a GenericValue and write it to the databasefindAllByPrimaryKeys
(List<GenericPK> primaryKeys) Find a number of Generic Value objects by their Primary Keys, all at once This is done here for the DAO GenericHelper; for a client-server helper it would be done on the server side to reduce network round trips.findByMultiRelation
(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) findByPrimaryKey
(GenericPK primaryKey) Find a Generic Entity by its Primary KeyfindByPrimaryKeyPartial
(GenericPK primaryKey, Set<String> keys) Find a Generic Entity by its Primary Key and only returns the values requested by the passed keys (names)long
findCountByCondition
(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, List<ModelField> selectFields, EntityFindOptions findOptions) long
findCountByCondition
(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) findListIteratorByCondition
(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions) Finds GenericValues by the conditions specified in the EntityCondition object, the the EntityCondition javadoc for more details.Gets the name of the server configuration that corresponds to this helperint
removeByCondition
(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) Removes/deletes Generic Entity records found by all the specified conditionint
removeByPrimaryKey
(GenericPK primaryKey) Remove a Generic Entity corresponding to the primaryKeyint
store
(GenericValue value) Store the Entity from the GenericValue to the persistent storeint
storeByCondition
(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) Updates a group of values in a single pass.
-
Constructor Details
-
GenericHelperDAO
-
-
Method Details
-
getHelperName
Description copied from interface:GenericHelper
Gets the name of the server configuration that corresponds to this helper- Specified by:
getHelperName
in interfaceGenericHelper
- Returns:
- server configuration name
-
create
Creates a Entity in the form of a GenericValue and write it to the database- Specified by:
create
in interfaceGenericHelper
- Returns:
- GenericValue instance containing the new instance
- Throws:
GenericEntityException
-
findByPrimaryKey
Find a Generic Entity by its Primary Key- Specified by:
findByPrimaryKey
in interfaceGenericHelper
- Parameters:
primaryKey
- The primary key to find by.- 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:
findByPrimaryKeyPartial
in interfaceGenericHelper
- 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(List<GenericPK> primaryKeys) throws GenericEntityException Find a number of Generic Value objects by their Primary Keys, all at once This is done here for the DAO GenericHelper; for a client-server helper it would be done on the server side to reduce network round trips.- Specified by:
findAllByPrimaryKeys
in interfaceGenericHelper
- Parameters:
primaryKeys
- A List of primary keys to find by.- Returns:
- List of GenericValue objects corresponding to the passed primaryKey objects
- Throws:
GenericEntityException
-
removeByPrimaryKey
Remove a Generic Entity corresponding to the primaryKey- Specified by:
removeByPrimaryKey
in interfaceGenericHelper
- Parameters:
primaryKey
- The primary key of the entity to remove.- Returns:
- int representing number of rows effected by this operation
- Throws:
GenericEntityException
-
findListIteratorByCondition
public EntityListIterator findListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions) throws GenericEntityException Finds GenericValues by the conditions specified in the EntityCondition object, the the EntityCondition javadoc for more details.- Specified by:
findListIteratorByCondition
in interfaceGenericHelper
- Parameters:
modelEntity
- 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 a " 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 (preferably in a finally block), AND DON'T LEAVE IT OPEN TOO LONG BECAUSE IT WILL MAINTAIN A DATABASE CONNECTION.
- Throws:
GenericEntityException
-
findByMultiRelation
public List<GenericValue> findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) throws GenericEntityException - Specified by:
findByMultiRelation
in interfaceGenericHelper
- Throws:
GenericEntityException
-
findCountByCondition
public long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException - Specified by:
findCountByCondition
in interfaceGenericHelper
- Throws:
GenericEntityException
-
findCountByCondition
public long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, List<ModelField> selectFields, EntityFindOptions findOptions) throws GenericEntityException - Specified by:
findCountByCondition
in interfaceGenericHelper
- Throws:
GenericEntityException
-
removeByCondition
public int removeByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException Removes/deletes Generic Entity records found by all the specified condition- Specified by:
removeByCondition
in interfaceGenericHelper
- Parameters:
modelEntity
- The ModelEntity of the Entity as defined in the entity XML filecondition
- The condition that restricts the list of removed values- Returns:
- int representing number of rows effected by this operation
- Throws:
GenericEntityException
-
store
Store the Entity from the GenericValue to the persistent store- Specified by:
store
in interfaceGenericHelper
- Parameters:
value
- GenericValue instance containing the entity- Returns:
- int representing number of rows effected by this operation
- Throws:
GenericEntityException
-
storeByCondition
public int storeByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityExceptionUpdates a group of values in a single pass.- Specified by:
storeByCondition
in interfaceGenericHelper
- Parameters:
modelEntity
- The ModelEntity of the Entity as defined in the entity XML filefieldsToSet
- The fields of the named entity to set in the databasecondition
- The condition that restricts the list of removed values- Returns:
- int representing number of rows effected by this operation
- Throws:
GenericEntityException
-
checkDataSource
public void checkDataSource(Map<String, ModelEntity> modelEntities, List<String> messages, boolean addMissing) throws GenericEntityExceptionCheck the datasource to make sure the entity definitions are correct, optionally adding missing entities or fields on the server- Specified by:
checkDataSource
in interfaceGenericHelper
- Parameters:
modelEntities
- Map of entityName names and ModelEntity valuesmessages
- List to put any result messages inaddMissing
- Flag indicating whether or not to add missing entities and fields on the server- Throws:
GenericEntityException
-