T - Domain object Typepublic abstract class JdbcBaseDao<T> extends java.lang.Object implements CommonDao<T>
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<java.lang.String> |
COLUMN_NAMES |
(package private) DataSourceRegistry |
dsr |
protected org.springframework.jdbc.core.JdbcTemplate |
jdbcTemplate |
protected java.lang.String |
myPkName |
protected SchemaTable |
myTable |
protected org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate |
namedTemplate |
protected java.lang.String[] |
RETURN_PK_NAME |
protected java.lang.String |
TABLE_NAME |
FieldTypes| Modifier | Constructor and Description |
|---|---|
protected |
JdbcBaseDao(SchemaTable table) |
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<NVPair> |
convertToList(NVPair... values) |
static java.util.List<QueryTerm> |
convertToList(QueryTerm... values) |
int |
delete(java.util.List<QueryTerm> terms) |
int |
delete(QueryInstance qi) |
int |
delete(QueryTerm term) |
int |
deleteById(int dbid) |
boolean |
exists(java.util.List<QueryTerm> terms) |
boolean |
exists(QueryTerm term)
Determines whether one or more rows exist matching all of the specified fields with exact values.
|
java.util.List<java.lang.Integer> |
findAllIds(java.util.List<QueryTerm> terms)
Returns the list of row IDs matching all of the specified fields with exact values.
|
java.util.List<java.lang.Integer> |
findAllIds(QueryInstance qi) |
java.util.List<java.lang.Integer> |
findAllIds(QueryTerm term) |
java.util.List<T> |
findAllObjects()
Returns the list of domain objects from all rows in the table.
|
java.util.List<T> |
findAllObjects(java.util.List<QueryTerm> terms)
Returns the list of domain objects matching all of the specified fields with exact values.
|
java.util.List<T> |
findAllObjects(QueryInstance qi) |
java.util.List<T> |
findAllObjects(QueryTerm term) |
T |
findById(int dbId)
Returns the domain object for the specified internal database ID.
|
int |
findId(java.util.List<QueryTerm> terms) |
int |
findId(QueryTerm term)
Returns the first IDs matching all of the specified fields with exact values.
|
java.util.List<T> |
findMultipleObjects(java.util.List<QueryTerm> terms,
int limit) |
java.util.List<T> |
findMultipleObjects(java.util.List<QueryTerm> terms,
int start,
int limit) |
T |
findObject(java.util.List<QueryTerm> terms)
Returns the object matching all of the specified fields with exact values.
|
T |
findObject(QueryInstance qi)
Returns the object matching the specified query.
|
T |
findObject(QueryTerm value)
Returns the object matching the specified query term.
|
int |
getCount(java.util.List<QueryTerm> terms) |
int |
getCount(QueryInstance qi) |
int |
getCount(QueryTerm term)
Returns the number of rows matching all of the specified fields with exact values.
|
protected abstract NVPairList |
getNVPairs(T obj) |
protected abstract org.springframework.jdbc.core.RowMapper<T> |
getRowMapper() |
protected void |
initOnce(javax.sql.DataSource dataSource,
java.lang.String tableName,
java.util.List<java.lang.String> expectedColNames) |
int |
persist(T obj)
Inserts a row in the current table.
|
void |
update(int dbId,
java.util.List<NVPair> values)
Updates a row in the current table
|
void |
update(int dbId,
NVPair value) |
void |
update(int dbId,
T obj)
Updates a row in the current table.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetFieldDefnsprotected SchemaTable myTable
protected java.lang.String myPkName
protected java.lang.String TABLE_NAME
protected java.util.List<java.lang.String> COLUMN_NAMES
protected java.lang.String[] RETURN_PK_NAME
protected org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate namedTemplate
protected org.springframework.jdbc.core.JdbcTemplate jdbcTemplate
@Autowired DataSourceRegistry dsr
protected JdbcBaseDao(SchemaTable table)
protected abstract NVPairList getNVPairs(T obj)
protected abstract org.springframework.jdbc.core.RowMapper<T> getRowMapper()
public int persist(T obj)
CommonDaopublic void update(int dbId,
T obj)
throws NotFoundException
CommonDaoupdate in interface CommonDao<T>dbId - The internal database ID for the row to modify. A caller should be able to
obtain this value by getting it directly from the obj.obj - Source object for updating the table row's fields.NotFoundException - If no such row existspublic void update(int dbId,
NVPair value)
throws NotFoundException
update in interface CommonDao<T>NotFoundExceptionpublic void update(int dbId,
java.util.List<NVPair> values)
throws NotFoundException
CommonDaoupdate in interface CommonDao<T>dbId - The internal database ID for the row to modify.values - A list of Pairs containing the field names (from the enum element
defined in the concrete class) and values to change.NotFoundException - If no such row existspublic T findById(int dbId) throws NotFoundException
CommonDaofindById in interface CommonDao<T>dbId - Internal database ID for the row to return.NotFoundException - If no such row exists@SafeVarargs public static final java.util.List<NVPair> convertToList(NVPair... values)
@SafeVarargs public static final java.util.List<QueryTerm> convertToList(QueryTerm... values)
public int findId(QueryTerm term) throws NotFoundException
CommonDaofield1 = value1 AND field2 = value2 AND ...
findId in interface CommonDao<T>NotFoundException - If no such row existspublic int findId(java.util.List<QueryTerm> terms) throws NotFoundException
findId in interface CommonDao<T>NotFoundExceptionpublic java.util.List<java.lang.Integer> findAllIds(java.util.List<QueryTerm> terms)
CommonDaofindAllIds in interface CommonDao<T>terms - A list of Pairs containing field names (as the enum element
defined in the concrete class) and values to search on.public java.util.List<java.lang.Integer> findAllIds(QueryTerm term)
findAllIds in interface CommonDao<T>public java.util.List<java.lang.Integer> findAllIds(QueryInstance qi)
findAllIds in interface CommonDao<T>public final java.util.List<T> findAllObjects() throws NotFoundException
CommonDaoNote: Use with caution. findAllObjects() is intentende for use on tables containing a modest number of rows.
findAllObjects in interface CommonDao<T>NotFoundException - If no rows existpublic T findObject(QueryTerm value) throws NotFoundException
CommonDaofindObject in interface CommonDao<T>value - A single termNotFoundException - If no such row existspublic T findObject(java.util.List<QueryTerm> terms) throws NotFoundException
CommonDaofindObject in interface CommonDao<T>terms - A list of Pairs containing field names (as the enum element
defined in the concrete class) and values to search on.NotFoundException - If no such row existspublic java.util.List<T> findAllObjects(QueryTerm term) throws NotFoundException
findAllObjects in interface CommonDao<T>NotFoundExceptionpublic java.util.List<T> findAllObjects(java.util.List<QueryTerm> terms) throws NotFoundException
CommonDaofindAllObjects in interface CommonDao<T>terms - A list of Pairs containing field names (as the enum element
defined in the concrete class) and values to search on.NotFoundException - If no rows existpublic java.util.List<T> findMultipleObjects(java.util.List<QueryTerm> terms, int limit) throws NotFoundException
findMultipleObjects in interface CommonDao<T>NotFoundExceptionpublic java.util.List<T> findMultipleObjects(java.util.List<QueryTerm> terms, int start, int limit)
findMultipleObjects in interface CommonDao<T>public java.util.List<T> findAllObjects(QueryInstance qi) throws NotFoundException
findAllObjects in interface CommonDao<T>NotFoundExceptionpublic T findObject(QueryInstance qi) throws NotFoundException
CommonDaofindObject in interface CommonDao<T>qi - A QueryInstance derived from a QueryBuilderNotFoundException - If no such row existspublic boolean exists(QueryTerm term)
CommonDaopublic boolean exists(java.util.List<QueryTerm> terms)
public int getCount(QueryTerm term)
CommonDaopublic int getCount(java.util.List<QueryTerm> terms)
public int getCount(QueryInstance qi)
protected void initOnce(javax.sql.DataSource dataSource,
java.lang.String tableName,
java.util.List<java.lang.String> expectedColNames)
public int deleteById(int dbid)
deleteById in interface CommonDao<T>public int delete(java.util.List<QueryTerm> terms)
public int delete(QueryInstance qi)