public class GenericDao
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
keysGeneratedByDatabase |
Constructor and Description |
---|
GenericDao() |
Modifier and Type | Method and Description |
---|---|
long |
count(java.lang.Class entityType)
Counts number of all entities.
|
void |
decreaseProperty(java.lang.Class entityType,
long id,
java.lang.String name,
java.lang.Number delta)
Decreases a property.
|
void |
deleteAllById(java.util.Collection objects)
Deletes all objects by their id.
|
void |
deleteById(java.lang.Class entityType,
long id)
Deleted single entity by its id.
|
void |
deleteById(java.lang.Object entity)
Delete single object by its id.
|
<E> java.util.List<E> |
find(java.lang.Class<E> entityType,
java.lang.Object criteria)
Finds list of entities matching given criteria.
|
<E> java.util.List<E> |
find(java.lang.Object criteria)
Finds list of entities matching given criteria.
|
<E> E |
findById(java.lang.Class<E> entityType,
long id)
Finds single entity by its id.
|
<E> E |
findOne(java.lang.Object criteria)
Finds one entity for given criteria.
|
<E> E |
findOneByProperty(java.lang.Class<E> entityType,
java.lang.String name,
java.lang.Object value)
Finds single entity by matching property.
|
<E> java.util.List<E> |
findRelated(java.lang.Class<E> target,
java.lang.Object source)
Finds related entity.
|
protected long |
generateNextId(DbEntityDescriptor ded)
Generates next id for given type.
|
void |
increaseProperty(java.lang.Class entityType,
long id,
java.lang.String name,
java.lang.Number delta)
Increases a property.
|
boolean |
isKeysGeneratedByDatabase()
Returns
true if keys are auto-generated by database. |
protected <E> boolean |
isPersistent(DbEntityDescriptor<E> ded,
E entity)
Returns
true if entity is persistent. |
<E> java.util.List<E> |
listAll(java.lang.Class<E> target)
List all entities.
|
void |
save(java.lang.Object entity)
Simply inserts object into the database.
|
void |
saveAll(java.util.Collection entities)
Inserts bunch of objects into the database.
|
protected <E> void |
setEntityId(DbEntityDescriptor<E> ded,
E entity,
long newValue)
Sets new ID value for entity.
|
void |
setKeysGeneratedByDatabase(boolean keysGeneratedByDatabase)
Specifies how primary keys are generated.
|
<E> E |
store(E entity)
Saves or updates entity.
|
void |
update(java.lang.Object entity)
Updates single entity.
|
void |
updateAll(java.util.Collection entities)
Updates all entities.
|
<E> E |
updateProperty(E entity,
java.lang.String name)
Updates property in the database by storing the current property value.
|
<E> E |
updateProperty(E entity,
java.lang.String name,
java.lang.Object newValue)
Updates single property in database and in the bean.
|
public boolean isKeysGeneratedByDatabase()
true
if keys are auto-generated by database.
Otherwise, keys are generated manually.public void setKeysGeneratedByDatabase(boolean keysGeneratedByDatabase)
protected <E> boolean isPersistent(DbEntityDescriptor<E> ded, E entity)
true
if entity is persistent.protected <E> void setEntityId(DbEntityDescriptor<E> ded, E entity, long newValue)
protected long generateNextId(DbEntityDescriptor ded)
public <E> E store(E entity)
null
, entity will be updated.
Otherwise, entity will be inserted into the database.public void save(java.lang.Object entity)
public void saveAll(java.util.Collection entities)
save(Object)
public void update(java.lang.Object entity)
public void updateAll(java.util.Collection entities)
update(Object)
public <E> E updateProperty(E entity, java.lang.String name, java.lang.Object newValue)
public <E> E updateProperty(E entity, java.lang.String name)
public <E> E findById(java.lang.Class<E> entityType, long id)
public <E> E findOneByProperty(java.lang.Class<E> entityType, java.lang.String name, java.lang.Object value)
public <E> E findOne(java.lang.Object criteria)
public <E> java.util.List<E> find(java.lang.Object criteria)
public <E> java.util.List<E> find(java.lang.Class<E> entityType, java.lang.Object criteria)
public void deleteById(java.lang.Class entityType, long id)
public void deleteById(java.lang.Object entity)
public void deleteAllById(java.util.Collection objects)
public long count(java.lang.Class entityType)
public void increaseProperty(java.lang.Class entityType, long id, java.lang.String name, java.lang.Number delta)
public void decreaseProperty(java.lang.Class entityType, long id, java.lang.String name, java.lang.Number delta)
public <E> java.util.List<E> findRelated(java.lang.Class<E> target, java.lang.Object source)
public <E> java.util.List<E> listAll(java.lang.Class<E> target)
Copyright © 2003-present Jodd Team