Class GenericDAO
- java.lang.Object
-
- org.apache.ofbiz.entity.datasource.GenericDAO
-
public class GenericDAO extends java.lang.Object
Generic Entity Data Access Object - Handles persistence for any defined entity.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
module
-
Constructor Summary
Constructors Constructor Description GenericDAO(GenericHelperInfo helperInfo)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
checkDb(java.util.Map<java.lang.String,ModelEntity> modelEntities, java.util.List<java.lang.String> messages, boolean addMissing)
int
delete(GenericEntity entity)
int
delete(GenericEntity entity, SQLProcessor sqlP)
int
deleteByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition)
int
deleteByCondition(ModelEntity modelEntity, EntityCondition condition, SQLProcessor sqlP)
static GenericDAO
getGenericDAO(GenericHelperInfo helperInfo)
java.util.List<ModelEntity>
induceModelFromDb(java.util.Collection<java.lang.String> messages)
Creates a list of ModelEntity objects based on meta data from the databaseint
insert(GenericEntity entity)
protected java.lang.StringBuilder
makeConditionHavingString(java.lang.StringBuilder havingString, java.lang.String prefix, ModelEntity modelEntity, EntityCondition havingEntityCondition, java.util.List<EntityCondition> viewHavingConditions, java.util.List<EntityConditionParam> havingEntityConditionParams)
protected java.lang.StringBuilder
makeConditionHavingString(ModelEntity modelEntity, EntityCondition havingEntityCondition, java.util.List<EntityCondition> viewHavingConditions, java.util.List<EntityConditionParam> havingEntityConditionParams)
Deprecated.protected java.lang.StringBuilder
makeConditionWhereString(java.lang.StringBuilder whereString, java.lang.String prefix, ModelEntity modelEntity, EntityCondition whereEntityCondition, java.util.List<EntityCondition> viewWhereConditions, java.util.List<EntityConditionParam> whereEntityConditionParams)
protected java.lang.StringBuilder
makeConditionWhereString(ModelEntity modelEntity, EntityCondition whereEntityCondition, java.util.List<EntityCondition> viewWhereConditions, java.util.List<EntityConditionParam> whereEntityConditionParams)
Deprecated.protected java.lang.StringBuilder
makeOffsetString(java.lang.StringBuilder offsetString, EntityFindOptions findOptions)
void
partialSelect(GenericEntity entity, java.util.Set<java.lang.String> keys)
void
select(GenericEntity entity)
void
select(GenericEntity entity, SQLProcessor sqlP)
java.util.List<GenericValue>
selectByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, java.util.List<java.lang.String> orderBy)
long
selectCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, java.util.List<ModelField> selectFields, EntityFindOptions findOptions)
long
selectCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions)
EntityListIterator
selectListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, java.util.Collection<java.lang.String> fieldsToSelect, java.util.List<java.lang.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)
int
updateAll(GenericEntity entity)
int
updateByCondition(Delegator delegator, ModelEntity modelEntity, java.util.Map<java.lang.String,? extends java.lang.Object> fieldsToSet, EntityCondition condition)
int
updateByCondition(ModelEntity modelEntity, java.util.Map<java.lang.String,? extends java.lang.Object> fieldsToSet, EntityCondition condition, SQLProcessor sqlP)
-
-
-
Constructor Detail
-
GenericDAO
public GenericDAO(GenericHelperInfo helperInfo)
-
-
Method Detail
-
getGenericDAO
public static GenericDAO getGenericDAO(GenericHelperInfo helperInfo)
-
insert
public int insert(GenericEntity entity) throws GenericEntityException
- Throws:
GenericEntityException
-
updateAll
public int updateAll(GenericEntity entity) throws GenericEntityException
- Throws:
GenericEntityException
-
update
public int update(GenericEntity entity) throws GenericEntityException
- Throws:
GenericEntityException
-
updateByCondition
public int updateByCondition(Delegator delegator, ModelEntity modelEntity, java.util.Map<java.lang.String,? extends java.lang.Object> fieldsToSet, EntityCondition condition) throws GenericEntityException
- Throws:
GenericEntityException
-
updateByCondition
public int updateByCondition(ModelEntity modelEntity, java.util.Map<java.lang.String,? extends java.lang.Object> fieldsToSet, EntityCondition condition, SQLProcessor sqlP) throws GenericEntityException
- Throws:
GenericEntityException
-
select
public void select(GenericEntity entity) throws GenericEntityException
- Throws:
GenericEntityException
-
select
public void select(GenericEntity entity, SQLProcessor sqlP) throws GenericEntityException
- Throws:
GenericEntityException
-
partialSelect
public void partialSelect(GenericEntity entity, java.util.Set<java.lang.String> keys) throws GenericEntityException
- Throws:
GenericEntityException
-
selectListIteratorByCondition
public EntityListIterator selectListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, java.util.Collection<java.lang.String> fieldsToSelect, java.util.List<java.lang.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 java.lang.StringBuilder makeConditionWhereString(ModelEntity modelEntity, EntityCondition whereEntityCondition, java.util.List<EntityCondition> viewWhereConditions, java.util.List<EntityConditionParam> whereEntityConditionParams) throws GenericEntityException
Deprecated.- Throws:
GenericEntityException
-
makeConditionWhereString
protected java.lang.StringBuilder makeConditionWhereString(java.lang.StringBuilder whereString, java.lang.String prefix, ModelEntity modelEntity, EntityCondition whereEntityCondition, java.util.List<EntityCondition> viewWhereConditions, java.util.List<EntityConditionParam> whereEntityConditionParams) throws GenericEntityException
- Throws:
GenericEntityException
-
makeConditionHavingString
@Deprecated protected java.lang.StringBuilder makeConditionHavingString(ModelEntity modelEntity, EntityCondition havingEntityCondition, java.util.List<EntityCondition> viewHavingConditions, java.util.List<EntityConditionParam> havingEntityConditionParams) throws GenericEntityException
Deprecated.- Throws:
GenericEntityException
-
makeConditionHavingString
protected java.lang.StringBuilder makeConditionHavingString(java.lang.StringBuilder havingString, java.lang.String prefix, ModelEntity modelEntity, EntityCondition havingEntityCondition, java.util.List<EntityCondition> viewHavingConditions, java.util.List<EntityConditionParam> havingEntityConditionParams) throws GenericEntityException
- Throws:
GenericEntityException
-
makeOffsetString
protected java.lang.StringBuilder makeOffsetString(java.lang.StringBuilder offsetString, EntityFindOptions findOptions)
-
selectByMultiRelation
public java.util.List<GenericValue> selectByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, java.util.List<java.lang.String> orderBy) throws GenericEntityException
- Throws:
GenericEntityException
-
selectCountByCondition
public long selectCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException
- Throws:
GenericEntityException
-
selectCountByCondition
public long selectCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, java.util.List<ModelField> selectFields, EntityFindOptions findOptions) throws GenericEntityException
- Throws:
GenericEntityException
-
delete
public int delete(GenericEntity entity) throws GenericEntityException
- Throws:
GenericEntityException
-
delete
public int delete(GenericEntity entity, SQLProcessor sqlP) throws GenericEntityException
- Throws:
GenericEntityException
-
deleteByCondition
public int deleteByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException
- Throws:
GenericEntityException
-
deleteByCondition
public int deleteByCondition(ModelEntity modelEntity, EntityCondition condition, SQLProcessor sqlP) throws GenericEntityException
- Throws:
GenericEntityException
-
checkDb
public void checkDb(java.util.Map<java.lang.String,ModelEntity> modelEntities, java.util.List<java.lang.String> messages, boolean addMissing)
-
induceModelFromDb
public java.util.List<ModelEntity> induceModelFromDb(java.util.Collection<java.lang.String> messages)
Creates a list of ModelEntity objects based on meta data from the database
-
-