Class GenericDAO
java.lang.Object
org.apache.ofbiz.entity.datasource.GenericDAO
Generic Entity Data Access Object - Handles persistence for any defined entity.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Check db.int
delete
(GenericEntity entity) Delete int.int
delete
(GenericEntity entity, SQLProcessor sqlP) Delete int.int
deleteByCondition
(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) Delete by condition int.int
deleteByCondition
(ModelEntity modelEntity, EntityCondition condition, SQLProcessor sqlP) Delete by condition int.static GenericDAO
getGenericDAO
(GenericHelperInfo helperInfo) induceModelFromDb
(Collection<String> messages) Creates a list of ModelEntity objects based on meta data from the databaseint
insert
(GenericEntity entity) Insert int.protected StringBuilder
makeConditionHavingString
(StringBuilder havingString, String prefix, ModelEntity modelEntity, EntityCondition havingEntityCondition, List<EntityCondition> viewHavingConditions, List<EntityConditionParam> havingEntityConditionParams) Make condition having string string builder.protected StringBuilder
makeConditionHavingString
(ModelEntity modelEntity, EntityCondition havingEntityCondition, List<EntityCondition> viewHavingConditions, List<EntityConditionParam> havingEntityConditionParams) Deprecated.protected StringBuilder
makeConditionWhereString
(StringBuilder whereString, String prefix, ModelEntity modelEntity, EntityCondition whereEntityCondition, List<EntityCondition> viewWhereConditions, List<EntityConditionParam> whereEntityConditionParams) Make condition where string string builder.protected StringBuilder
makeConditionWhereString
(ModelEntity modelEntity, EntityCondition whereEntityCondition, List<EntityCondition> viewWhereConditions, List<EntityConditionParam> whereEntityConditionParams) Deprecated.protected StringBuilder
makeOffsetString
(StringBuilder offsetString, EntityFindOptions findOptions) Make offset string string builder.void
partialSelect
(GenericEntity entity, Set<String> keys) Partial select.void
select
(GenericEntity entity) Select.void
select
(GenericEntity entity, SQLProcessor sqlP) Select.selectByMultiRelation
(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) Select by multi relation list.long
selectCountByCondition
(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, List<ModelField> selectFields, EntityFindOptions findOptions) Select count by condition long.long
selectCountByCondition
(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) Select count by condition long.selectListIteratorByCondition
(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.int
update
(GenericEntity entity) Update int.int
updateAll
(GenericEntity entity) Update all int.int
updateByCondition
(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) Update by condition int.int
updateByCondition
(ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition, SQLProcessor sqlP) Update by condition int.
-
Constructor Details
-
GenericDAO
-
-
Method Details
-
getGenericDAO
-
insert
Insert int.- Parameters:
entity
- the entity- Returns:
- the int
- Throws:
GenericEntityException
- the generic entity exception
-
updateAll
Update all int.- Parameters:
entity
- the entity- Returns:
- the int
- Throws:
GenericEntityException
- the generic entity exception
-
update
Update int.- Parameters:
entity
- the entity- Returns:
- the int
- Throws:
GenericEntityException
- the generic entity exception
-
updateByCondition
public int updateByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityExceptionUpdate by condition int.- Parameters:
delegator
- the delegatormodelEntity
- the model entityfieldsToSet
- the fields to setcondition
- the condition- Returns:
- the int
- Throws:
GenericEntityException
- the generic entity exception
-
updateByCondition
public int updateByCondition(ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition, SQLProcessor sqlP) throws GenericEntityExceptionUpdate by condition int.- Parameters:
modelEntity
- the model entityfieldsToSet
- the fields to setcondition
- the conditionsqlP
- the sql p- Returns:
- the int
- Throws:
GenericEntityException
- the generic entity exception
-
select
Select.- Parameters:
entity
- the entity- Throws:
GenericEntityException
- the generic entity exception
-
select
Select.- Parameters:
entity
- the entitysqlP
- the sql p- Throws:
GenericEntityException
- the generic entity exception
-
partialSelect
Partial select.- Parameters:
entity
- the entitykeys
- the keys- Throws:
GenericEntityException
- the generic entity exception
-
selectListIteratorByCondition
public EntityListIterator selectListIteratorByCondition(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.- 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
-
makeConditionWhereString
@Deprecated protected StringBuilder makeConditionWhereString(ModelEntity modelEntity, EntityCondition whereEntityCondition, List<EntityCondition> viewWhereConditions, List<EntityConditionParam> whereEntityConditionParams) throws GenericEntityException Deprecated.Make condition where string string builder.- Parameters:
modelEntity
- the model entitywhereEntityCondition
- the where entity conditionviewWhereConditions
- the view where conditionswhereEntityConditionParams
- the where entity condition params- Returns:
- the string builder
- Throws:
GenericEntityException
- the generic entity exception
-
makeConditionWhereString
protected StringBuilder makeConditionWhereString(StringBuilder whereString, String prefix, ModelEntity modelEntity, EntityCondition whereEntityCondition, List<EntityCondition> viewWhereConditions, List<EntityConditionParam> whereEntityConditionParams) throws GenericEntityException Make condition where string string builder.- Parameters:
whereString
- the where stringprefix
- the prefixmodelEntity
- the model entitywhereEntityCondition
- the where entity conditionviewWhereConditions
- the view where conditionswhereEntityConditionParams
- the where entity condition params- Returns:
- the string builder
- Throws:
GenericEntityException
- the generic entity exception
-
makeConditionHavingString
@Deprecated protected StringBuilder makeConditionHavingString(ModelEntity modelEntity, EntityCondition havingEntityCondition, List<EntityCondition> viewHavingConditions, List<EntityConditionParam> havingEntityConditionParams) throws GenericEntityException Deprecated.Make condition having string string builder.- Parameters:
modelEntity
- the model entityhavingEntityCondition
- the having entity conditionviewHavingConditions
- the view having conditionshavingEntityConditionParams
- the having entity condition params- Returns:
- the string builder
- Throws:
GenericEntityException
- the generic entity exception
-
makeConditionHavingString
protected StringBuilder makeConditionHavingString(StringBuilder havingString, String prefix, ModelEntity modelEntity, EntityCondition havingEntityCondition, List<EntityCondition> viewHavingConditions, List<EntityConditionParam> havingEntityConditionParams) throws GenericEntityException Make condition having string string builder.- Parameters:
havingString
- the having stringprefix
- the prefixmodelEntity
- the model entityhavingEntityCondition
- the having entity conditionviewHavingConditions
- the view having conditionshavingEntityConditionParams
- the having entity condition params- Returns:
- the string builder
- Throws:
GenericEntityException
- the generic entity exception
-
makeOffsetString
Make offset string string builder.- Parameters:
offsetString
- the offset stringfindOptions
- the find options- Returns:
- the string builder
-
selectByMultiRelation
public List<GenericValue> selectByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) throws GenericEntityException Select by multi relation list.- Parameters:
value
- the valuemodelRelationOne
- the model relation onemodelEntityOne
- the model entity onemodelRelationTwo
- the model relation twomodelEntityTwo
- the model entity twoorderBy
- the order by- Returns:
- the list
- Throws:
GenericEntityException
- the generic entity exception
-
selectCountByCondition
public long selectCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException Select count by condition long.- Parameters:
delegator
- the delegatormodelEntity
- the model entitywhereEntityCondition
- the where entity conditionhavingEntityCondition
- the having entity conditionfindOptions
- the find options- Returns:
- the long
- Throws:
GenericEntityException
- the generic entity exception
-
selectCountByCondition
public long selectCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, List<ModelField> selectFields, EntityFindOptions findOptions) throws GenericEntityException Select count by condition long.- Parameters:
delegator
- the delegatormodelEntity
- the model entitywhereEntityCondition
- the where entity conditionhavingEntityCondition
- the having entity conditionselectFields
- the select fieldsfindOptions
- the find options- Returns:
- the long
- Throws:
GenericEntityException
- the generic entity exception
-
delete
Delete int.- Parameters:
entity
- the entity- Returns:
- the int
- Throws:
GenericEntityException
- the generic entity exception
-
delete
Delete int.- Parameters:
entity
- the entitysqlP
- the sql p- Returns:
- the int
- Throws:
GenericEntityException
- the generic entity exception
-
deleteByCondition
public int deleteByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException Delete by condition int.- Parameters:
delegator
- the delegatormodelEntity
- the model entitycondition
- the condition- Returns:
- the int
- Throws:
GenericEntityException
- the generic entity exception
-
deleteByCondition
public int deleteByCondition(ModelEntity modelEntity, EntityCondition condition, SQLProcessor sqlP) throws GenericEntityException Delete by condition int.- Parameters:
modelEntity
- the model entitycondition
- the conditionsqlP
- the sql p- Returns:
- the int
- Throws:
GenericEntityException
- the generic entity exception
-
checkDb
public void checkDb(Map<String, ModelEntity> modelEntities, List<String> messages, boolean addMissing) Check db.- Parameters:
modelEntities
- the model entitiesmessages
- the messagesaddMissing
- the add missing
-
induceModelFromDb
Creates a list of ModelEntity objects based on meta data from the database
-