public class GenericDAO extends Object
| Modifier and Type | Field and Description |
|---|---|
protected DatasourceInfo |
datasourceInfo |
protected static Map<String,GenericDAO> |
genericDAOs |
protected String |
helperName |
protected ModelFieldTypeReader |
modelFieldTypeReader |
static String |
module |
static int |
MS_SQL_MAX_PARAMETER_COUNT |
static int |
ORACLE_MAX_LIST_SIZE |
| Constructor and Description |
|---|
GenericDAO(String helperName) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkDb(Map<String,? extends ModelEntity> modelEntities,
Collection<String> messages,
boolean addMissing) |
int |
count(ModelEntity modelEntity,
String fieldName,
EntityCondition entityCondition,
EntityFindOptions findOptions) |
int |
delete(GenericEntity entity) |
int |
deleteAll(List<? extends GenericEntity> dummyPKs)
Called dummyPKs because they can be invalid PKs, doing a deleteByAnd instead of a normal delete
|
int |
deleteByAnd(ModelEntity modelEntity,
Map<String,?> fields) |
int |
deleteByCondition(ModelEntity modelEntity,
EntityCondition whereCondition) |
static GenericDAO |
getGenericDAO(String helperName) |
List<ModelEntity> |
induceModelFromDb(Collection<String> messages)
Creates a list of ModelEntity objects based on meta data from the database
|
int |
insert(GenericEntity entity) |
void |
partialSelect(GenericEntity entity,
Set<String> keys) |
static void |
removeGenericDAO(String helperName) |
void |
select(GenericEntity entity) |
void |
select(GenericEntity entity,
Connection connection) |
List<GenericValue> |
selectByAnd(ModelEntity modelEntity,
Map<String,?> fields,
List<String> orderBy) |
List<GenericValue> |
selectByCondition(ModelEntity modelEntity,
EntityCondition entityCondition,
Collection<String> fieldsToSelect,
List<String> orderBy)
Finds GenericValues by the conditions specified in the EntityCondition object, see the EntityCondition javadoc
for more details.
|
List<GenericValue> |
selectByCondition(ModelEntity modelEntity,
EntityCondition entityCondition,
Collection<String> fieldsToSelect,
List<String> orderBy,
EntityFindOptions findOptions)
Finds GenericValues by the conditions specified in the EntityCondition object, see the EntityCondition javadoc
for more details.
|
List<GenericValue> |
selectByMultiRelation(GenericValue value,
ModelRelation modelRelationOne,
ModelEntity modelEntityOne,
ModelRelation modelRelationTwo,
ModelEntity modelEntityTwo,
List<String> orderBy) |
List<GenericValue> |
selectByOr(ModelEntity modelEntity,
Map<String,?> fields,
List<String> orderBy) |
EntityListIterator |
selectListIteratorByCondition(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 |
storeAll(List<? extends GenericEntity> entities) |
List<GenericValue> |
transform(ModelEntity modelEntity,
EntityCondition entityCondition,
List<String> orderBy,
String lockFieldName,
Transformation transformation)
Applies the given transformation to any entities matching the given
condition, by performing a SELECT followed by an UPDATE.
|
int |
update(GenericEntity entity)
Updates the given entity with the given non-PK values.
|
int |
update(GenericEntity entity,
EntityConditionParam nonPkCondition)
Updates the given entity with the given non-PK values.
|
int |
updateAll(GenericEntity entity) |
public static final String module
public static final int ORACLE_MAX_LIST_SIZE
public static final int MS_SQL_MAX_PARAMETER_COUNT
protected static Map<String,GenericDAO> genericDAOs
protected String helperName
protected ModelFieldTypeReader modelFieldTypeReader
protected DatasourceInfo datasourceInfo
public GenericDAO(String helperName)
public static void removeGenericDAO(String helperName)
public static GenericDAO getGenericDAO(String helperName)
public int insert(GenericEntity entity) throws GenericEntityException
GenericEntityExceptionpublic int updateAll(GenericEntity entity) throws GenericEntityException
GenericEntityExceptionpublic int update(GenericEntity entity) throws GenericEntityException
entity - the values to store (except the primary key fields, which
are used to identify the row to be updated)GenericEntityNotFoundException - if the entity can't be foundGenericEntityException - if some other problem occurredpublic int update(GenericEntity entity, EntityConditionParam nonPkCondition) throws GenericEntityException
entity - the values to store (except the primary key fields, which
are used to identify the row to be updated)nonPkCondition - an optional non-PK condition upon the updateGenericEntityNotFoundException - if the entity wasn't found by its PK or doesn't meet the non-PK condition,
if anyGenericEntityExceptionpublic int storeAll(List<? extends GenericEntity> entities) throws GenericEntityException
GenericEntityExceptionpublic void select(GenericEntity entity) throws GenericEntityException
GenericEntityExceptionpublic void select(GenericEntity entity, Connection connection) throws GenericEntityException
GenericEntityExceptionpublic void partialSelect(GenericEntity entity, Set<String> keys) throws GenericEntityException
GenericEntityExceptionpublic List<GenericValue> selectByAnd(ModelEntity modelEntity, Map<String,?> fields, List<String> orderBy) throws GenericEntityException
GenericEntityExceptionpublic List<GenericValue> selectByOr(ModelEntity modelEntity, Map<String,?> fields, List<String> orderBy) throws GenericEntityException
GenericEntityExceptionpublic List<GenericValue> selectByCondition(ModelEntity modelEntity, EntityCondition entityCondition, Collection<String> fieldsToSelect, List<String> orderBy) throws GenericEntityException
modelEntity - The ModelEntity of the Entity as defined in the entity 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 to order the query by; optionally add a " ASC" for ascending or
" DESC" for descendingGenericEntityExceptionpublic List<GenericValue> selectByCondition(ModelEntity modelEntity, EntityCondition entityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions) throws GenericEntityException
modelEntity - The ModelEntity of the Entity as defined in the entity 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 to order the query by; optionally add a " ASC" for ascending orfindOptions - if null, the default options will be used
" DESC" for descendingGenericEntityExceptionpublic EntityListIterator selectListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions) throws GenericEntityException
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 - can be null to use the default optionsGenericEntityExceptionpublic List<GenericValue> selectByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) throws GenericEntityException
GenericEntityExceptionpublic int delete(GenericEntity entity) throws GenericEntityException
GenericEntityExceptionpublic int deleteByCondition(ModelEntity modelEntity, EntityCondition whereCondition) throws GenericEntityException
GenericEntityExceptionpublic int deleteByAnd(ModelEntity modelEntity, Map<String,?> fields) throws GenericEntityException
GenericEntityExceptionpublic int deleteAll(List<? extends GenericEntity> dummyPKs) throws GenericEntityException
GenericEntityExceptionpublic void checkDb(Map<String,? extends ModelEntity> modelEntities, Collection<String> messages, boolean addMissing)
public List<ModelEntity> induceModelFromDb(Collection<String> messages)
public int count(ModelEntity modelEntity, String fieldName, EntityCondition entityCondition, EntityFindOptions findOptions) throws GenericEntityException
GenericEntityExceptionpublic List<GenericValue> transform(ModelEntity modelEntity, EntityCondition entityCondition, List<String> orderBy, String lockFieldName, Transformation transformation) throws GenericEntityException
modelEntity - 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)lockFieldName - 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)GenericEntityExceptionCopyright © 2016 Atlassian. All rights reserved.