Package com.landawn.abacus.jdbc.dao
Interface CrudDao<T,ID,SB extends com.landawn.abacus.util.SQLBuilder,TD extends CrudDao<T,ID,SB,TD>>
- Type Parameters:
T
-ID
- useVoid
if there is no id defined/annotated with@Id
in target entity classT
.SB
-SQLBuilder
used to generate sql scripts. Only can beSQLBuilder.PSC/PAC/PLC
- All Superinterfaces:
Dao<T,
SB, TD>
- All Known Subinterfaces:
CrudDaoL<T,
,SB, TD> NoUpdateCrudDao<T,
,ID, SB, TD> NoUpdateCrudDaoL<T,
,SB, TD> ReadOnlyCrudDao<T,
,ID, SB, TD> ReadOnlyCrudDaoL<T,
,SB, TD> UncheckedCrudDao<T,
,ID, SB, TD> UncheckedCrudDaoL<T,
,SB, TD> UncheckedNoUpdateCrudDao<T,
,ID, SB, TD> UncheckedNoUpdateCrudDaoL<T,
,SB, TD> UncheckedReadOnlyCrudDao<T,
,ID, SB, TD> UncheckedReadOnlyCrudDaoL<T,
SB, TD>
public interface CrudDao<T,ID,SB extends com.landawn.abacus.util.SQLBuilder,TD extends CrudDao<T,ID,SB,TD>>
extends Dao<T,SB,TD>
The Interface CrudDao.
- See Also:
-
JdbcUtil.prepareQuery(javax.sql.DataSource, String)
JdbcUtil.prepareNamedQuery(javax.sql.DataSource, String)
JdbcUtil.beginTransaction(javax.sql.DataSource, IsolationLevel, boolean)
Dao
SQLExecutor.Mapper
ConditionFactory
ConditionFactory.CF
-
Method Summary
Modifier and TypeMethodDescriptiondefault int
batchDelete
(Collection<? extends T> entities) int
batchDelete
(Collection<? extends T> entities, int batchSize) default int
batchDeleteByIds
(Collection<? extends ID> ids) int
batchDeleteByIds
(Collection<? extends ID> ids, int batchSize) batchGet
(Collection<? extends ID> ids) batchGet
(Collection<? extends ID> ids, int batchSize) batchGet
(Collection<? extends ID> ids, Collection<String> selectPropNames) batchGet
(Collection<? extends ID> ids, Collection<String> selectPropNames, int batchSize) batchInsert
(String namedInsertSQL, Collection<? extends T> entities) batchInsert
(String namedInsertSQL, Collection<? extends T> entities, int batchSize) batchInsert
(Collection<? extends T> entities) batchInsert
(Collection<? extends T> entities, int batchSize) batchInsert
(Collection<? extends T> entities, Collection<String> propNamesToInsert) batchInsert
(Collection<? extends T> entities, Collection<String> propNamesToInsert, int batchSize) default int
batchRefresh
(Collection<? extends T> entities) default int
batchRefresh
(Collection<? extends T> entities, int batchSize) default int
batchRefresh
(Collection<? extends T> entities, Collection<String> propNamesToRefresh) default int
batchRefresh
(Collection<? extends T> entities, Collection<String> propNamesToRefresh, int batchSize) default int
batchUpdate
(Collection<? extends T> entities) int
batchUpdate
(Collection<? extends T> entities, int batchSize) default int
batchUpdate
(Collection<? extends T> entities, Collection<String> propNamesToUpdate) int
batchUpdate
(Collection<? extends T> entities, Collection<String> propNamesToUpdate, int batchSize) batchUpsert
(Collection<? extends T> entities) batchUpsert
(Collection<? extends T> entities, int batchSize) int
count
(Collection<ID> ids) Count the records in db by inputids
.int
int
deleteById
(ID id) Delete by id.boolean
default ID
Deprecated.unsupported Operationdefault com.landawn.abacus.util.u.Optional<T>
default com.landawn.abacus.util.u.Optional<T>
get
(ID id, Collection<String> selectPropNames) gett
(ID id, Collection<String> selectPropNames) default Jdbc.BiRowMapper<ID>
insert
(T entityToInsert, Collection<String> propNamesToInsert) default boolean
com.landawn.abacus.util.u.OptionalBoolean
queryForBoolean
(String singleSelectPropName, ID id) Query for boolean.com.landawn.abacus.util.u.OptionalByte
queryForByte
(String singleSelectPropName, ID id) Query for byte.com.landawn.abacus.util.u.OptionalChar
queryForChar
(String singleSelectPropName, ID id) Query for char.com.landawn.abacus.util.u.Nullable<Date>
queryForDate
(String singleSelectPropName, ID id) Query for date.com.landawn.abacus.util.u.OptionalDouble
queryForDouble
(String singleSelectPropName, ID id) Query for double.com.landawn.abacus.util.u.OptionalFloat
queryForFloat
(String singleSelectPropName, ID id) Query for float.com.landawn.abacus.util.u.OptionalInt
queryForInt
(String singleSelectPropName, ID id) Query for int.com.landawn.abacus.util.u.OptionalLong
queryForLong
(String singleSelectPropName, ID id) Query for long.com.landawn.abacus.util.u.OptionalShort
queryForShort
(String singleSelectPropName, ID id) Query for short.<V> com.landawn.abacus.util.u.Optional<V>
queryForSingleNonNull
(Class<V> targetValueClass, String singleSelectPropName, ID id) Query for single non null.<V> com.landawn.abacus.util.u.Nullable<V>
queryForSingleResult
(Class<V> targetValueClass, String singleSelectPropName, ID id) Query for single result.com.landawn.abacus.util.u.Nullable<String>
queryForString
(String singleSelectPropName, ID id) Query for string.com.landawn.abacus.util.u.Nullable<Time>
queryForTime
(String singleSelectPropName, ID id) Query for time.com.landawn.abacus.util.u.Nullable<Timestamp>
queryForTimestamp
(String singleSelectPropName, ID id) Query for timestamp.<V> com.landawn.abacus.util.u.Optional<V>
queryForUniqueNonNull
(Class<V> targetValueClass, String singleSelectPropName, ID id) Query for unique non null.<V> com.landawn.abacus.util.u.Nullable<V>
queryForUniqueResult
(Class<V> targetValueClass, String singleSelectPropName, ID id) Query for unique result.default boolean
default boolean
refresh
(T entity, Collection<String> propNamesToRefresh) default int
int
int
int
update
(T entityToUpdate, Collection<String> propNamesToUpdate) default T
Executeadd
and return the added entity if the record doesn't, otherwise,update
is executed and updated db record is returned.default T
Executeadd
and return the added entity if the record doesn't, otherwise,update
is executed and updated db record is returned.Methods inherited from interface com.landawn.abacus.jdbc.dao.Dao
asyncCall, asyncCall, asyncExecutor, asyncRun, asyncRun, batchSave, batchSave, batchSave, batchSave, batchSave, batchSave, count, dataSource, delete, executor, exists, findFirst, findFirst, findFirst, findFirst, findFirst, findFirst, findOnlyOne, findOnlyOne, findOnlyOne, findOnlyOne, findOnlyOne, findOnlyOne, foreach, foreach, forEach, forEach, forEach, forEach, forEach, forEach, forEach, forEach, list, list, list, list, list, list, list, list, list, list, list, list, list, notExists, prepareCallableQuery, prepareCallableQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQuery, prepareNamedQueryForBigResult, prepareNamedQueryForBigResult, prepareNamedQueryForBigResult, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQueryForBigResult, prepareQueryForBigResult, prepareQueryForBigResult, query, query, query, query, query, query, queryForBoolean, queryForByte, queryForChar, queryForDate, queryForDouble, queryForFloat, queryForInt, queryForLong, queryForShort, queryForSingleNonNull, queryForSingleResult, queryForString, queryForTime, queryForTimestamp, queryForUniqueNonNull, queryForUniqueResult, save, save, save, sqlMapper, stream, stream, stream, stream, stream, stream, stream, stream, stream, stream, stream, stream, stream, targetEntityClass, update, update, update, update
-
Method Details
-
idExtractor
-
generateId
Deprecated.unsupported Operation- Returns:
- Throws:
UnsupportedOperationException
SQLException
-
insert
- Parameters:
entityToInsert
-- Returns:
- Throws:
SQLException
-
insert
- Parameters:
entityToInsert
-propNamesToInsert
-- Returns:
- Throws:
SQLException
-
insert
- Parameters:
namedInsertSQL
-entityToInsert
-- Returns:
- Throws:
SQLException
-
batchInsert
- Parameters:
entities
-- Returns:
- Throws:
SQLException
-
batchInsert
- Parameters:
entities
-batchSize
-- Returns:
- Throws:
SQLException
-
batchInsert
default List<ID> batchInsert(Collection<? extends T> entities, Collection<String> propNamesToInsert) throws SQLException - Parameters:
entities
-propNamesToInsert
-- Returns:
- Throws:
SQLException
-
batchInsert
List<ID> batchInsert(Collection<? extends T> entities, Collection<String> propNamesToInsert, int batchSize) throws SQLException - Parameters:
entities
-propNamesToInsert
-batchSize
-- Returns:
- Throws:
SQLException
-
batchInsert
@Beta default List<ID> batchInsert(String namedInsertSQL, Collection<? extends T> entities) throws SQLException - Parameters:
namedInsertSQL
-entities
-- Returns:
- Throws:
SQLException
-
batchInsert
@Beta List<ID> batchInsert(String namedInsertSQL, Collection<? extends T> entities, int batchSize) throws SQLException - Parameters:
namedInsertSQL
-entities
-batchSize
-- Returns:
- Throws:
SQLException
-
queryForBoolean
com.landawn.abacus.util.u.OptionalBoolean queryForBoolean(String singleSelectPropName, ID id) throws SQLException Query for boolean.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForChar
com.landawn.abacus.util.u.OptionalChar queryForChar(String singleSelectPropName, ID id) throws SQLException Query for char.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForByte
com.landawn.abacus.util.u.OptionalByte queryForByte(String singleSelectPropName, ID id) throws SQLException Query for byte.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForShort
com.landawn.abacus.util.u.OptionalShort queryForShort(String singleSelectPropName, ID id) throws SQLException Query for short.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForInt
com.landawn.abacus.util.u.OptionalInt queryForInt(String singleSelectPropName, ID id) throws SQLException Query for int.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForLong
com.landawn.abacus.util.u.OptionalLong queryForLong(String singleSelectPropName, ID id) throws SQLException Query for long.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForFloat
com.landawn.abacus.util.u.OptionalFloat queryForFloat(String singleSelectPropName, ID id) throws SQLException Query for float.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForDouble
com.landawn.abacus.util.u.OptionalDouble queryForDouble(String singleSelectPropName, ID id) throws SQLException Query for double.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForString
com.landawn.abacus.util.u.Nullable<String> queryForString(String singleSelectPropName, ID id) throws SQLException Query for string.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForDate
com.landawn.abacus.util.u.Nullable<Date> queryForDate(String singleSelectPropName, ID id) throws SQLException Query for date.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForTime
com.landawn.abacus.util.u.Nullable<Time> queryForTime(String singleSelectPropName, ID id) throws SQLException Query for time.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForTimestamp
com.landawn.abacus.util.u.Nullable<Timestamp> queryForTimestamp(String singleSelectPropName, ID id) throws SQLException Query for timestamp.- Parameters:
singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForSingleResult
<V> com.landawn.abacus.util.u.Nullable<V> queryForSingleResult(Class<V> targetValueClass, String singleSelectPropName, ID id) throws SQLException Query for single result.- Type Parameters:
V
- the value type- Parameters:
targetValueClass
-singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForSingleNonNull
<V> com.landawn.abacus.util.u.Optional<V> queryForSingleNonNull(Class<V> targetValueClass, String singleSelectPropName, ID id) throws SQLException Query for single non null.- Type Parameters:
V
- the value type- Parameters:
targetValueClass
-singleSelectPropName
-id
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(oridition
).SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForUniqueResult
<V> com.landawn.abacus.util.u.Nullable<V> queryForUniqueResult(Class<V> targetValueClass, String singleSelectPropName, ID id) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException Query for unique result.- Type Parameters:
V
- the value type- Parameters:
targetValueClass
-singleSelectPropName
-id
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(oridition
).SQLException
- See Also:
-
IDFactory
IDFactory.CF
-
queryForUniqueNonNull
<V> com.landawn.abacus.util.u.Optional<V> queryForUniqueNonNull(Class<V> targetValueClass, String singleSelectPropName, ID id) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException Query for unique non null.- Type Parameters:
V
- the value type- Parameters:
targetValueClass
-singleSelectPropName
-id
-- Returns:
- Throws:
SQLException
com.landawn.abacus.exception.DuplicatedResultException
- See Also:
-
IDFactory
IDFactory.CF
-
get
default com.landawn.abacus.util.u.Optional<T> get(ID id) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Parameters:
id
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
-
get
default com.landawn.abacus.util.u.Optional<T> get(ID id, Collection<String> selectPropNames) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Parameters:
id
-selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
-
gett
- Parameters:
id
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
-
gett
T gett(ID id, Collection<String> selectPropNames) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Parameters:
id
-selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
-
batchGet
default List<T> batchGet(Collection<? extends ID> ids) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Parameters:
ids
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if the size of result is bigger than the size of inputids
.SQLException
-
batchGet
default List<T> batchGet(Collection<? extends ID> ids, int batchSize) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Parameters:
ids
-batchSize
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if the size of result is bigger than the size of inputids
.SQLException
-
batchGet
default List<T> batchGet(Collection<? extends ID> ids, Collection<String> selectPropNames) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Parameters:
ids
-selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
. all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if the size of result is bigger than the size of inputids
.SQLException
-
batchGet
List<T> batchGet(Collection<? extends ID> ids, Collection<String> selectPropNames, int batchSize) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Parameters:
ids
-selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
. all properties(columns) will be selected, excluding the properties of joining entities, ifselectPropNames
isnull
.batchSize
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if the size of result is bigger than the size of inputids
.SQLException
-
exists
- Parameters:
id
-- Returns:
- true, if successful
- Throws:
SQLException
- See Also:
-
notExists
- Parameters:
id
-- Returns:
- Throws:
SQLException
- See Also:
-
count
Count the records in db by inputids
.- Parameters:
ids
-- Returns:
- Throws:
SQLException
-
update
- Parameters:
entityToUpdate
-- Returns:
- Throws:
SQLException
-
update
- Parameters:
entityToUpdate
-propNamesToUpdate
-- Returns:
- Throws:
SQLException
-
update
- Parameters:
propName
-propValue
-id
-- Returns:
- Throws:
SQLException
-
update
- Parameters:
updateProps
-id
-- Returns:
- Throws:
SQLException
-
batchUpdate
- Parameters:
entities
-- Returns:
- Throws:
SQLException
-
batchUpdate
- Parameters:
entities
-batchSize
-- Returns:
- Throws:
SQLException
-
batchUpdate
default int batchUpdate(Collection<? extends T> entities, Collection<String> propNamesToUpdate) throws SQLException - Parameters:
entities
-propNamesToUpdate
-- Returns:
- Throws:
SQLException
-
batchUpdate
int batchUpdate(Collection<? extends T> entities, Collection<String> propNamesToUpdate, int batchSize) throws SQLException - Parameters:
entities
-propNamesToUpdate
-batchSize
-- Returns:
- Throws:
SQLException
-
upsert
Executeadd
and return the added entity if the record doesn't, otherwise,update
is executed and updated db record is returned. -
upsert
Executeadd
and return the added entity if the record doesn't, otherwise,update
is executed and updated db record is returned.- Parameters:
entity
-- Returns:
- Throws:
SQLException
-
batchUpsert
- Parameters:
entities
-- Returns:
- Throws:
SQLException
-
batchUpsert
- Parameters:
entities
-batchSize
-- Returns:
- Throws:
SQLException
-
refresh
- Parameters:
entity
-- Returns:
- true, if successful
- Throws:
SQLException
-
refresh
- Parameters:
entity
-propNamesToRefresh
-- Returns:
false
if no record found by the ids in the specifiedentity
.- Throws:
SQLException
-
batchRefresh
- Parameters:
entities
-- Returns:
- the count of refreshed entities.
- Throws:
SQLException
-
batchRefresh
- Parameters:
entities
-batchSize
-- Returns:
- the count of refreshed entities.
- Throws:
SQLException
-
batchRefresh
default int batchRefresh(Collection<? extends T> entities, Collection<String> propNamesToRefresh) throws SQLException - Parameters:
entities
-propNamesToRefresh
-- Returns:
- the count of refreshed entities.
- Throws:
SQLException
-
batchRefresh
default int batchRefresh(Collection<? extends T> entities, Collection<String> propNamesToRefresh, int batchSize) throws SQLException - Parameters:
entities
-propNamesToRefresh
-batchSize
-- Returns:
- the count of refreshed entities.
- Throws:
SQLException
-
delete
- Parameters:
entity
-- Returns:
- Throws:
SQLException
-
deleteById
Delete by id.- Parameters:
id
-- Returns:
- Throws:
SQLException
-
batchDelete
- Parameters:
entities
-- Returns:
- Throws:
SQLException
-
batchDelete
- Parameters:
entities
-batchSize
-- Returns:
- Throws:
SQLException
-
batchDeleteByIds
- Parameters:
ids
-- Returns:
- Throws:
SQLException
-
batchDeleteByIds
- Parameters:
ids
-batchSize
-- Returns:
- Throws:
SQLException
-