Package com.landawn.abacus.jdbc.dao
Interface Dao<T,SB extends com.landawn.abacus.util.SQLBuilder,TD extends Dao<T,SB,TD>>
- Type Parameters:
T
-SB
-SQLBuilder
used to generate sql scripts. Only can beSQLBuilder.PSC/PAC/PLC
TD
-
- All Known Subinterfaces:
CrudDao<T,
,ID, SB, TD> CrudDaoL<T,
,SB, TD> NoUpdateCrudDao<T,
,ID, SB, TD> NoUpdateCrudDaoL<T,
,SB, TD> NoUpdateDao<T,
,SB, TD> ReadOnlyCrudDao<T,
,ID, SB, TD> ReadOnlyCrudDaoL<T,
,SB, TD> ReadOnlyDao<T,
,SB, TD> UncheckedCrudDao<T,
,ID, SB, TD> UncheckedCrudDaoL<T,
,SB, TD> UncheckedDao<T,
,SB, TD> UncheckedNoUpdateCrudDao<T,
,ID, SB, TD> UncheckedNoUpdateCrudDaoL<T,
,SB, TD> UncheckedNoUpdateDao<T,
,SB, TD> UncheckedReadOnlyCrudDao<T,
,ID, SB, TD> UncheckedReadOnlyCrudDaoL<T,
,SB, TD> UncheckedReadOnlyDao<T,
SB, TD>
public interface Dao<T,SB extends com.landawn.abacus.util.SQLBuilder,TD extends Dao<T,SB,TD>>
Performance Tips:
Avoid unnecessary/repeated database calls.
Only fetch the columns you need or update the columns you want.
Index is the key point in a lot of database performance issues.
This interface is designed to share/manager SQL queries by Java APIs/methods with static parameter types and return type, while hiding the SQL scripts. It's a gift from nature and created by thoughts.
Note: Setting parameters by 'ParametersSetter' or Retrieving result/record by 'ResultExtractor/BiResultExtractor/RowMapper/BiRowMapper' is not enabled at present.
The SQL operations/methods should be annotated with SQL scripts by
The Order of the parameters in the method should be consistent with parameter order in SQL scripts for parameterized SQL.
For named parameterized SQL, the parameters must be binded with names through
SQL parameters can be set through input method parameters(by multiple parameters or a
The return type of the method must be same as the return type of
The return type of update/delete operations only can int/Integer/long/Long/boolean/Boolean/void. If it's long/Long,
Remember declaring
Which underline
Here is a simple
This interface is designed to share/manager SQL queries by Java APIs/methods with static parameter types and return type, while hiding the SQL scripts. It's a gift from nature and created by thoughts.
Note: Setting parameters by 'ParametersSetter' or Retrieving result/record by 'ResultExtractor/BiResultExtractor/RowMapper/BiRowMapper' is not enabled at present.
@Select/@Insert/@Update/@Delete/@NamedSelect/@NamedInsert/@NamedUpdate/@NamedDelete
.@Bind
, or Map/Entity
with getter/setter methods.Collection
, or a Map/Entity
for named sql), or by JdbcUtil.ParametersSetter<PreparedQuery/PreparedCallabeQuery...>
.ResultExtractor/BiResultExtractor/RowMapper/BiRowMapper
can be specified by the last parameter of the method.ResultExtractor/BiResultExtractor
if it's specified by the last parameter of the method.PreparedQuery#largeUpdate()
will be called,
otherwise, PreparedQuery#update()
will be called.throws SQLException
in the method.PreparedQuery/PreparedCallableQuery
method to call for SQL methods/operations annotated with @Select/@NamedSelect
:
- If
ResultExtractor/BiResultExtractor
is specified by the last parameter of the method,PreparedQuery#query(ResultExtractor/BiResultExtractor)
will be called. - Or else if
RowMapper/BiRowMapper
is specified by the last parameter of the method: - If the return type of the method is
List
and one of below conditions is matched,PreparedQuery#list(RowMapper/BiRowMapper)
will be called: - The return type of the method is raw
List
without parameterized type, and the method name doesn't start with"get"/"findFirst"/"findOne"/"findOnlyOne"
. - The last parameter type is raw
RowMapper/BiRowMapper
without parameterized type, and the method name doesn't start with"get"/"findFirst"/"findOne"/"findOnlyOne"
. - The return type of the method is generic
List
with parameterized type and The last parameter type is genericRowMapper/BiRowMapper
with parameterized types, but They're not same. - Or else if the return type of the method is
ExceptionalStream/Stream
,PreparedQuery#stream(RowMapper/BiRowMapper)
will be called. - Or else if the return type of the method is
Optional
,PreparedQuery#findFirst(RowMapper/BiRowMapper)
will be called. - Or else,
PreparedQuery#findFirst(RowMapper/BiRowMapper).orElse(N.defaultValueOf(returnType))
will be called. - Or else:
- If the return type of the method is
DataSet
,PreparedQuery#query()
will be called. - Or else if the return type of the method is
ExceptionalStream/Stream
,PreparedQuery#stream(Class)
will be called. - Or else if the return type of the method is
Map
orEntity
class withgetter/setter
methods,PreparedQuery#findFirst(Class).orElseNull()
will be called. - Or else if the return type of the method is
Optional
: - If the value type of
Optional
isMap
, orEntity
class withgetter/setter
methods, orList
, orObject[]
,PreparedQuery#findFirst(Class)
will be called. - Or else,
PreparedQuery#queryForSingleNonNull(Class)
will be called. - Or else if the return type of the method is
Nullable
: - If the value type of
Nullable
isMap
, orEntity
class withgetter/setter
methods, orList
, orObject[]
,PreparedQuery#findFirst(Class)
will be called. - Or else,
PreparedQuery#queryForSingleResult(Class)
will be called. - Or else if the return type of the method is
OptionalBoolean/Byte/.../Double
,PreparedQuery#queryForBoolean/Byte/...Double()
will called. - Or else if the return type of the method is
List
, and the method name doesn't start with"get"/"findFirst"/"findOne"/"findOnlyOne"
,PreparedQuery#list(Class)
will be called. - Or else if the return type of the method is
boolean/Boolean
, and the method name starts with"exist"/"exists"/"notExist"/"notExists"
,PreparedQuery#exists()
orPreparedQuery#notExists()
will be called. - Or else,
PreparedQuery#queryForSingleResult(Class).orElse(N.defaultValueOf(returnType)
will be called.
Here is a simple
UserDao
sample.
public static interface UserDao extends JdbcUtil.CrudDao<User, Long, SQLBuilder.PSC> {
@NamedInsert("INSERT INTO user (id, first_name, last_name, email) VALUES (:id, :firstName, :lastName, :email)")
void insertWithId(User user) throws SQLException;
@NamedUpdate("UPDATE user SET first_name = :firstName, last_name = :lastName WHERE id = :id")
int updateFirstAndLastName(@Bind("firstName") String newFirstName, @Bind("lastName") String newLastName, @Bind("id") long id) throws SQLException;
@NamedSelect("SELECT first_name, last_name FROM user WHERE id = :id")
User getFirstAndLastNameBy(@Bind("id") long id) throws SQLException;
@NamedSelect("SELECT id, first_name, last_name, email FROM user")
Stream allUsers() throws SQLException;
}
Here is the generate way to work with transaction started by SQLExecutor
.
static final UserDao userDao = Dao.newInstance(UserDao.class, dataSource);
...
final SQLTransaction tran = JdbcUtil.beginTransaction(dataSource, IsolationLevel.READ_COMMITTED);
try {
userDao.getById(id);
userDao.update(...);
// more...
tran.commit();
} finally {
// The connection will be automatically closed after the transaction is committed or rolled back.
tran.rollbackIfNotCommitted();
}
- See Also:
-
JdbcUtil.prepareQuery(javax.sql.DataSource, String)
JdbcUtil.prepareNamedQuery(javax.sql.DataSource, String)
JdbcUtil.beginTransaction(javax.sql.DataSource, IsolationLevel, boolean)
Dao
SQLExecutor.Mapper
AccessFieldByMethod
ConditionFactory
ConditionFactory.CF
- How to turn off the Eclipse code formatter for certain sections of Java code?
-
Method Summary
Modifier and TypeMethodDescriptiondefault <R> com.landawn.abacus.util.ContinuableFuture<R>
asyncCall
(com.landawn.abacus.util.Throwables.Function<TD, R, SQLException> sqlAction) Any transaction started in current thread won't be automatically applied to specifiedsqlAction
which will be executed in another thread.default <R> com.landawn.abacus.util.ContinuableFuture<R>
asyncCall
(com.landawn.abacus.util.Throwables.Function<TD, R, SQLException> sqlAction, Executor executor) Any transaction started in current thread won't be automatically applied to specifiedsqlAction
which will be executed in another thread.com.landawn.abacus.util.AsyncExecutor
Deprecated.for internal use only.default com.landawn.abacus.util.ContinuableFuture<Void>
asyncRun
(com.landawn.abacus.util.Throwables.Consumer<TD, SQLException> sqlAction) Any transaction started in current thread won't be automatically applied to specifiedsqlAction
which will be executed in another thread.default com.landawn.abacus.util.ContinuableFuture<Void>
asyncRun
(com.landawn.abacus.util.Throwables.Consumer<TD, SQLException> sqlAction, Executor executor) Any transaction started in current thread won't be automatically applied to specifiedsqlAction
which will be executed in another thread.default void
batchSave
(String namedInsertSQL, Collection<? extends T> entitiesToSave) Insert the specified entities to database by batch.void
batchSave
(String namedInsertSQL, Collection<? extends T> entitiesToSave, int batchSize) Insert the specified entities to database by batch.default void
batchSave
(Collection<? extends T> entitiesToSave) Insert the specified entities to database by batch.void
batchSave
(Collection<? extends T> entitiesToSave, int batchSize) Insert the specified entities to database by batch.default void
batchSave
(Collection<? extends T> entitiesToSave, Collection<String> propNamesToSave) Insert the specified entities to database by batch.void
batchSave
(Collection<? extends T> entitiesToSave, Collection<String> propNamesToSave, int batchSize) Insert the specified entities to database by batch.int
count
(com.landawn.abacus.condition.Condition cond) int
delete
(com.landawn.abacus.condition.Condition cond) executor()
Deprecated.for internal use only.boolean
exists
(com.landawn.abacus.condition.Condition cond) com.landawn.abacus.util.u.Optional<T>
findFirst
(com.landawn.abacus.condition.Condition cond) <R> com.landawn.abacus.util.u.Optional<R>
findFirst
(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) <R> com.landawn.abacus.util.u.Optional<R>
findFirst
(com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) com.landawn.abacus.util.u.Optional<T>
findFirst
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) <R> com.landawn.abacus.util.u.Optional<R>
findFirst
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) <R> com.landawn.abacus.util.u.Optional<R>
findFirst
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) com.landawn.abacus.util.u.Optional<T>
findOnlyOne
(com.landawn.abacus.condition.Condition cond) <R> com.landawn.abacus.util.u.Optional<R>
findOnlyOne
(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) <R> com.landawn.abacus.util.u.Optional<R>
findOnlyOne
(com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) com.landawn.abacus.util.u.Optional<T>
findOnlyOne
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) <R> com.landawn.abacus.util.u.Optional<R>
findOnlyOne
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) <R> com.landawn.abacus.util.u.Optional<R>
findOnlyOne
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) default void
foreach
(com.landawn.abacus.condition.Condition cond, Consumer<com.landawn.abacus.util.NoCachingNoUpdating.DisposableObjArray> rowConsumer) default void
foreach
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Consumer<com.landawn.abacus.util.NoCachingNoUpdating.DisposableObjArray> rowConsumer) void
forEach
(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowConsumer rowConsumer) void
forEach
(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowConsumer rowConsumer) void
forEach
(com.landawn.abacus.condition.Condition cond, Jdbc.RowConsumer rowConsumer) void
forEach
(com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowConsumer rowConsumer) void
forEach
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowConsumer rowConsumer) void
forEach
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowConsumer rowConsumer) void
forEach
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowConsumer rowConsumer) void
forEach
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowConsumer rowConsumer) list
(com.landawn.abacus.condition.Condition cond) <R> List<R>
list
(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<R> rowMapper) <R> List<R>
list
(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) <R> List<R>
list
(com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) <R> List<R>
list
(com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) default <R> List<R>
default <R> List<R>
list
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) default <R> List<R>
list
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) list
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) <R> List<R>
list
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<R> rowMapper) <R> List<R>
list
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) <R> List<R>
list
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) <R> List<R>
list
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) default boolean
notExists
(com.landawn.abacus.condition.Condition cond) default PreparedCallableQuery
prepareCallableQuery
(String query) default PreparedCallableQuery
prepareCallableQuery
(String sql, com.landawn.abacus.util.Throwables.BiFunction<Connection, String, CallableStatement, SQLException> stmtCreator) default NamedQuery
prepareNamedQuery
(com.landawn.abacus.condition.Condition cond) Prepare aselect
query by specifiedcond
.default NamedQuery
prepareNamedQuery
(com.landawn.abacus.util.ParsedSql namedSql) default NamedQuery
prepareNamedQuery
(com.landawn.abacus.util.ParsedSql namedSql, boolean generateKeys) default NamedQuery
prepareNamedQuery
(com.landawn.abacus.util.ParsedSql namedQuery, int[] returnColumnIndexes) default NamedQuery
prepareNamedQuery
(com.landawn.abacus.util.ParsedSql namedSql, com.landawn.abacus.util.Throwables.BiFunction<Connection, String, PreparedStatement, SQLException> stmtCreator) default NamedQuery
prepareNamedQuery
(com.landawn.abacus.util.ParsedSql namedQuery, String[] returnColumnNames) default NamedQuery
prepareNamedQuery
(String namedQuery) default NamedQuery
prepareNamedQuery
(String namedQuery, boolean generateKeys) default NamedQuery
prepareNamedQuery
(String namedQuery, int[] returnColumnIndexes) default NamedQuery
prepareNamedQuery
(String namedQuery, com.landawn.abacus.util.Throwables.BiFunction<Connection, String, PreparedStatement, SQLException> stmtCreator) default NamedQuery
prepareNamedQuery
(String namedQuery, String[] returnColumnNames) default NamedQuery
prepareNamedQuery
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) Prepare aselect
query by specifiedselectPropNames
andcond
.default NamedQuery
prepareNamedQueryForBigResult
(com.landawn.abacus.condition.Condition cond) Prepare a big resultselect
query by specifiedcond
.default NamedQuery
prepareNamedQueryForBigResult
(String namedQuery) default NamedQuery
prepareNamedQueryForBigResult
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) Prepare a big resultselect
query by specifiedselectPropNames
andcond
.default PreparedQuery
prepareQuery
(com.landawn.abacus.condition.Condition cond) Prepare aselect
query by specifiedcond
.default PreparedQuery
prepareQuery
(String query) default PreparedQuery
prepareQuery
(String query, boolean generateKeys) default PreparedQuery
prepareQuery
(String query, int[] returnColumnIndexes) default PreparedQuery
prepareQuery
(String sql, com.landawn.abacus.util.Throwables.BiFunction<Connection, String, PreparedStatement, SQLException> stmtCreator) default PreparedQuery
prepareQuery
(String query, String[] returnColumnNames) default PreparedQuery
prepareQuery
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) Prepare aselect
query by specifiedselectPropNames
andcond
.default PreparedQuery
prepareQueryForBigResult
(com.landawn.abacus.condition.Condition cond) Prepare a big resultselect
query by specifiedcond
.default PreparedQuery
prepareQueryForBigResult
(String query) default PreparedQuery
prepareQueryForBigResult
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) Prepare a big resultselect
query by specifiedselectPropNames
andcond
.com.landawn.abacus.util.DataSet
query
(com.landawn.abacus.condition.Condition cond) <R> R
query
(com.landawn.abacus.condition.Condition cond, Jdbc.BiResultExtractor<R> resultExtrator) <R> R
query
(com.landawn.abacus.condition.Condition cond, Jdbc.ResultExtractor<R> resultExtrator) com.landawn.abacus.util.DataSet
query
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) <R> R
query
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiResultExtractor<R> resultExtrator) <R> R
query
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.ResultExtractor<R> resultExtrator) com.landawn.abacus.util.u.OptionalBoolean
queryForBoolean
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for boolean.com.landawn.abacus.util.u.OptionalByte
queryForByte
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for byte.com.landawn.abacus.util.u.OptionalChar
queryForChar
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for char.com.landawn.abacus.util.u.Nullable<Date>
queryForDate
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for date.com.landawn.abacus.util.u.OptionalDouble
queryForDouble
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for double.com.landawn.abacus.util.u.OptionalFloat
queryForFloat
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for float.com.landawn.abacus.util.u.OptionalInt
queryForInt
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for int.com.landawn.abacus.util.u.OptionalLong
queryForLong
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for long.com.landawn.abacus.util.u.OptionalShort
queryForShort
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for short.<V> com.landawn.abacus.util.u.Optional<V>
queryForSingleNonNull
(Class<V> targetValueClass, String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for single non null.<V> com.landawn.abacus.util.u.Nullable<V>
queryForSingleResult
(Class<V> targetValueClass, String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for single result.com.landawn.abacus.util.u.Nullable<String>
queryForString
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for string.com.landawn.abacus.util.u.Nullable<Time>
queryForTime
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for time.com.landawn.abacus.util.u.Nullable<Timestamp>
queryForTimestamp
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for timestamp.<V> com.landawn.abacus.util.u.Optional<V>
queryForUniqueNonNull
(Class<V> targetValueClass, String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for unique non null.<V> com.landawn.abacus.util.u.Nullable<V>
queryForUniqueResult
(Class<V> targetValueClass, String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Query for unique result.void
void
void
save
(T entityToSave, Collection<String> propNamesToSave) com.landawn.abacus.util.SQLMapper
com.landawn.abacus.util.ExceptionalStream<T,
SQLException> stream
(com.landawn.abacus.condition.Condition cond) Lazy execution, lazy fetching.<R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<R> rowMapper) Lazy execution, lazy fetching.<R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) Lazy execution, lazy fetching.<R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching.<R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) lazy-execution, lazy-fetch.default <R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> Lazy execution, lazy fetching.default <R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching.default <R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(String singleSelectPropName, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching.com.landawn.abacus.util.ExceptionalStream<T,
SQLException> stream
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) Lazy execution, lazy fetching.<R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<R> rowMapper) Lazy execution, lazy fetching.<R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) Lazy execution, lazy fetching.<R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching.<R> com.landawn.abacus.util.ExceptionalStream<R,
SQLException> stream
(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching.Deprecated.for internal use only.default int
int
Update all the records found by specifiedcond
with all the properties from specifiedupdateProps
.default int
Update all the records found by specifiedcond
with the properties from specifiedentity
.int
update
(T entity, Collection<String> propNamesToUpdate, com.landawn.abacus.condition.Condition cond) Update all the records found by specifiedcond
with specifiedpropNamesToUpdate
from specifiedentity
.default T
Executeadd
and return the added entity if the record doesn't, otherwise,update
is executed and updated db record is returned.
-
Method Details
-
dataSource
DataSource dataSource()- Returns:
-
sqlMapper
com.landawn.abacus.util.SQLMapper sqlMapper()- Returns:
-
targetEntityClass
Deprecated.for internal use only.- Returns:
-
executor
Deprecated.for internal use only. -
asyncExecutor
Deprecated.for internal use only. -
prepareQuery
- Parameters:
query
-- Returns:
- Throws:
SQLException
-
prepareQuery
- Parameters:
query
-generateKeys
-- Returns:
- Throws:
SQLException
-
prepareQuery
@Beta default PreparedQuery prepareQuery(String query, int[] returnColumnIndexes) throws SQLException - Parameters:
query
-returnColumnIndexes
-- Returns:
- Throws:
SQLException
-
prepareQuery
@Beta default PreparedQuery prepareQuery(String query, String[] returnColumnNames) throws SQLException - Parameters:
query
-returnColumnIndexes
-- Returns:
- Throws:
SQLException
-
prepareQuery
@Beta default PreparedQuery prepareQuery(String sql, com.landawn.abacus.util.Throwables.BiFunction<Connection, String, throws SQLExceptionPreparedStatement, SQLException> stmtCreator) - Parameters:
sql
-stmtCreator
-- Returns:
- Throws:
SQLException
-
prepareQueryForBigResult
- Parameters:
query
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
- Parameters:
namedQuery
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(String namedQuery, boolean generateKeys) throws SQLException - Parameters:
namedQuery
-generateKeys
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(String namedQuery, int[] returnColumnIndexes) throws SQLException - Parameters:
namedQuery
-returnColumnIndexes
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(String namedQuery, String[] returnColumnNames) throws SQLException - Parameters:
namedQuery
-returnColumnNames
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(String namedQuery, com.landawn.abacus.util.Throwables.BiFunction<Connection, String, throws SQLExceptionPreparedStatement, SQLException> stmtCreator) - Parameters:
namedQuery
-stmtCreator
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(com.landawn.abacus.util.ParsedSql namedSql) throws SQLException - Parameters:
namedSql
- the named query- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(com.landawn.abacus.util.ParsedSql namedSql, boolean generateKeys) throws SQLException - Parameters:
namedSql
- the named querygenerateKeys
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(com.landawn.abacus.util.ParsedSql namedQuery, int[] returnColumnIndexes) throws SQLException - Parameters:
namedQuery
-returnColumnIndexes
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(com.landawn.abacus.util.ParsedSql namedQuery, String[] returnColumnNames) throws SQLException - Parameters:
namedQuery
-returnColumnNames
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(com.landawn.abacus.util.ParsedSql namedSql, com.landawn.abacus.util.Throwables.BiFunction<Connection, String, throws SQLExceptionPreparedStatement, SQLException> stmtCreator) - Parameters:
namedSql
- the named querystmtCreator
-- Returns:
- Throws:
SQLException
-
prepareNamedQueryForBigResult
- Parameters:
namedQuery
-- Returns:
- Throws:
SQLException
-
prepareCallableQuery
- Parameters:
query
-- Returns:
- Throws:
SQLException
-
prepareCallableQuery
@Beta default PreparedCallableQuery prepareCallableQuery(String sql, com.landawn.abacus.util.Throwables.BiFunction<Connection, String, throws SQLExceptionCallableStatement, SQLException> stmtCreator) - Parameters:
sql
-stmtCreator
-- Returns:
- Throws:
SQLException
-
prepareQuery
@Beta default PreparedQuery prepareQuery(com.landawn.abacus.condition.Condition cond) throws SQLException Prepare aselect
query by specifiedcond
.
query
could be aselect/insert/update/delete
or other sql statement. If it'sselect
by default if not specified.- Parameters:
cond
-- Returns:
- Throws:
SQLException
-
prepareQuery
@Beta default PreparedQuery prepareQuery(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) throws SQLException Prepare aselect
query by specifiedselectPropNames
andcond
.
query
could be aselect/insert/update/delete
or other sql statement. If it'sselect
by default if not specified.- Parameters:
selectPropNames
-cond
-- Returns:
- Throws:
SQLException
-
prepareQueryForBigResult
@Beta default PreparedQuery prepareQueryForBigResult(com.landawn.abacus.condition.Condition cond) throws SQLException Prepare a big resultselect
query by specifiedcond
.
query
could be aselect/insert/update/delete
or other sql statement. If it'sselect
by default if not specified.- Parameters:
cond
-- Returns:
- Throws:
SQLException
-
prepareQueryForBigResult
@Beta default PreparedQuery prepareQueryForBigResult(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) throws SQLException Prepare a big resultselect
query by specifiedselectPropNames
andcond
.
query
could be aselect/insert/update/delete
or other sql statement. If it'sselect
by default if not specified.- Parameters:
selectPropNames
-cond
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(com.landawn.abacus.condition.Condition cond) throws SQLException Prepare aselect
query by specifiedcond
.
query
could be aselect/insert/update/delete
or other sql statement. If it'sselect
by default if not specified.- Parameters:
cond
-- Returns:
- Throws:
SQLException
-
prepareNamedQuery
@Beta default NamedQuery prepareNamedQuery(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) throws SQLException Prepare aselect
query by specifiedselectPropNames
andcond
.
query
could be aselect/insert/update/delete
or other sql statement. If it'sselect
by default if not specified.- Parameters:
selectPropNames
-cond
-- Returns:
- Throws:
SQLException
-
prepareNamedQueryForBigResult
@Beta default NamedQuery prepareNamedQueryForBigResult(com.landawn.abacus.condition.Condition cond) throws SQLException Prepare a big resultselect
query by specifiedcond
.
query
could be aselect/insert/update/delete
or other sql statement. If it'sselect
by default if not specified.- Parameters:
cond
-- Returns:
- Throws:
SQLException
-
prepareNamedQueryForBigResult
@Beta default NamedQuery prepareNamedQueryForBigResult(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) throws SQLException Prepare a big resultselect
query by specifiedselectPropNames
andcond
.
query
could be aselect/insert/update/delete
or other sql statement. If it'sselect
by default if not specified.- Parameters:
selectPropNames
-cond
-- Returns:
- Throws:
SQLException
-
save
- Parameters:
entityToSave
-- Throws:
SQLException
-
save
- Parameters:
entityToSave
-propNamesToSave
-- Throws:
SQLException
-
save
- Parameters:
namedInsertSQL
-entityToSave
-- Throws:
SQLException
-
batchSave
Insert the specified entities to database by batch.- Parameters:
entitiesToSave
-- Throws:
SQLException
- See Also:
-
batchSave
Insert the specified entities to database by batch.- Parameters:
entitiesToSave
-batchSize
-- Throws:
SQLException
- See Also:
-
batchSave
default void batchSave(Collection<? extends T> entitiesToSave, Collection<String> propNamesToSave) throws SQLException Insert the specified entities to database by batch.- Parameters:
entitiesToSave
-propNamesToSave
-- Throws:
SQLException
- See Also:
-
batchSave
void batchSave(Collection<? extends T> entitiesToSave, Collection<String> propNamesToSave, int batchSize) throws SQLException Insert the specified entities to database by batch.- Parameters:
entitiesToSave
-propNamesToSave
-batchSize
-- Throws:
SQLException
- See Also:
-
batchSave
@Beta default void batchSave(String namedInsertSQL, Collection<? extends T> entitiesToSave) throws SQLException Insert the specified entities to database by batch.- Parameters:
namedInsertSQL
-entitiesToSave
-- Throws:
SQLException
- See Also:
-
batchSave
@Beta void batchSave(String namedInsertSQL, Collection<? extends T> entitiesToSave, int batchSize) throws SQLException Insert the specified entities to database by batch.- Parameters:
namedInsertSQL
-entitiesToSave
-batchSize
-- Throws:
SQLException
- See Also:
-
exists
- Parameters:
cond
-- Returns:
- true, if there is at least one record found.
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
AbstractPreparedQuery.exists()
-
notExists
- Parameters:
cond
-- Returns:
- true, if there is no record found.
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
AbstractPreparedQuery.notExists()
-
count
- Parameters:
cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findFirst
com.landawn.abacus.util.u.Optional<T> findFirst(com.landawn.abacus.condition.Condition cond) throws SQLException - Parameters:
cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findFirst
<R> com.landawn.abacus.util.u.Optional<R> findFirst(com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) throws SQLException, NullPointerException - Parameters:
cond
-rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findFirst
<R> com.landawn.abacus.util.u.Optional<R> findFirst(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) throws SQLException, NullPointerException - Parameters:
cond
-rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findFirst
com.landawn.abacus.util.u.Optional<T> findFirst(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) throws SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findFirst
<R> com.landawn.abacus.util.u.Optional<R> findFirst(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) throws SQLException, NullPointerException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findFirst
<R> com.landawn.abacus.util.u.Optional<R> findFirst(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) throws SQLException, NullPointerException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowMapper
-- Returns:
- Throws:
SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findOnlyOne
com.landawn.abacus.util.u.Optional<T> findOnlyOne(com.landawn.abacus.condition.Condition cond) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Parameters:
cond
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findOnlyOne
<R> com.landawn.abacus.util.u.Optional<R> findOnlyOne(com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException - Parameters:
cond
-rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findOnlyOne
<R> com.landawn.abacus.util.u.Optional<R> findOnlyOne(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException - Parameters:
cond
-rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findOnlyOne
com.landawn.abacus.util.u.Optional<T> findOnlyOne(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
findOnlyOne
<R> com.landawn.abacus.util.u.Optional<R> findOnlyOne(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.
-
findOnlyOne
<R> com.landawn.abacus.util.u.Optional<R> findOnlyOne(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException, NullPointerException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowMapper
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
NullPointerException
- ifrowMapper
returnsnull
for the found record.- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForBoolean
com.landawn.abacus.util.u.OptionalBoolean queryForBoolean(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for boolean.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForChar
com.landawn.abacus.util.u.OptionalChar queryForChar(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for char.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForByte
com.landawn.abacus.util.u.OptionalByte queryForByte(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for byte.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForShort
com.landawn.abacus.util.u.OptionalShort queryForShort(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for short.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForInt
com.landawn.abacus.util.u.OptionalInt queryForInt(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for int.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForLong
com.landawn.abacus.util.u.OptionalLong queryForLong(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for long.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForFloat
com.landawn.abacus.util.u.OptionalFloat queryForFloat(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for float.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForDouble
com.landawn.abacus.util.u.OptionalDouble queryForDouble(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for double.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForString
com.landawn.abacus.util.u.Nullable<String> queryForString(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for string.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForDate
com.landawn.abacus.util.u.Nullable<Date> queryForDate(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for date.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForTime
com.landawn.abacus.util.u.Nullable<Time> queryForTime(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for time.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForTimestamp
com.landawn.abacus.util.u.Nullable<Timestamp> queryForTimestamp(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for timestamp.- Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForSingleResult
<V> com.landawn.abacus.util.u.Nullable<V> queryForSingleResult(Class<V> targetValueClass, String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for single result.- Type Parameters:
V
- the value type- Parameters:
targetValueClass
-singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForSingleNonNull
<V> com.landawn.abacus.util.u.Optional<V> queryForSingleNonNull(Class<V> targetValueClass, String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException Query for single non null.- Type Parameters:
V
- the value type- Parameters:
targetValueClass
-singleSelectPropName
-cond
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForUniqueResult
<V> com.landawn.abacus.util.u.Nullable<V> queryForUniqueResult(Class<V> targetValueClass, String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException Query for unique result.- Type Parameters:
V
- the value type- Parameters:
targetValueClass
-singleSelectPropName
-cond
-- Returns:
- Throws:
com.landawn.abacus.exception.DuplicatedResultException
- if more than one record found by the specifiedid
(orcondition
).SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
queryForUniqueNonNull
<V> com.landawn.abacus.util.u.Optional<V> queryForUniqueNonNull(Class<V> targetValueClass, String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws com.landawn.abacus.exception.DuplicatedResultException, SQLException Query for unique non null.- Type Parameters:
V
- the value type- Parameters:
targetValueClass
-singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
com.landawn.abacus.exception.DuplicatedResultException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
query
com.landawn.abacus.util.DataSet query(com.landawn.abacus.condition.Condition cond) throws SQLException - Parameters:
cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
query
com.landawn.abacus.util.DataSet query(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) throws SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
query
<R> R query(com.landawn.abacus.condition.Condition cond, Jdbc.ResultExtractor<R> resultExtrator) throws SQLException - Parameters:
cond
-resultExtrator
- Don't save/returnResultSet
. It will be closed after this call.- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
query
<R> R query(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.ResultExtractor<R> resultExtrator) throws SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-resultExtrator
- Don't save/returnResultSet
. It will be closed after this call.- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
query
<R> R query(com.landawn.abacus.condition.Condition cond, Jdbc.BiResultExtractor<R> resultExtrator) throws SQLException - Parameters:
cond
-resultExtrator
- Don't save/returnResultSet
. It will be closed after this call.- Returns:
- Throws:
SQLException
-
query
<R> R query(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiResultExtractor<R> resultExtrator) throws SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-resultExtrator
- Don't save/returnResultSet
. It will be closed after this call.- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
- Parameters:
cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
<R> List<R> list(com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) throws SQLException - Parameters:
cond
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
<R> List<R> list(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) throws SQLException - Parameters:
cond
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
<R> List<R> list(com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) throws SQLException - Parameters:
cond
-rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
<R> List<R> list(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<R> rowMapper) throws SQLException - Parameters:
cond
-rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
List<T> list(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) throws SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
<R> List<R> list(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) throws SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
<R> List<R> list(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) throws SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
<R> List<R> list(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) throws SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
<R> List<R> list(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<R> rowMapper) throws SQLException - Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
default <R> List<R> list(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) throws SQLException - Parameters:
singleSelectPropName
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
default <R> List<R> list(String singleSelectPropName, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) throws SQLException - Parameters:
singleSelectPropName
-cond
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
list
default <R> List<R> list(String singleSelectPropName, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) throws SQLException - Parameters:
singleSelectPropName
-cond
-rowFilter
-rowMapper
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
com.landawn.abacus.util.ExceptionalStream<T,SQLException> stream(com.landawn.abacus.condition.Condition cond) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
cond
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
<R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) lazy-execution, lazy-fetch.- Parameters:
cond
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
<R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
cond
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
<R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
cond
-rowFilter
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
<R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<R> rowMapper) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
cond
-rowFilter
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
com.landawn.abacus.util.ExceptionalStream<T,SQLException> stream(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
<R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
<R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowMapper<R> rowMapper) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
<R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowFilter
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
<R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowMapper<R> rowMapper) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
selectPropNames
- all properties(columns) will be selected, excluding the properties of joining entities, if the specifiedselectPropNames
isnull
.cond
-rowFilter
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
default <R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(String singleSelectPropName, com.landawn.abacus.condition.Condition cond) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
singleSelectPropName
-cond
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
default <R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(String singleSelectPropName, com.landawn.abacus.condition.Condition cond, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
singleSelectPropName
-cond
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
stream
default <R> com.landawn.abacus.util.ExceptionalStream<R,SQLException> stream(String singleSelectPropName, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowMapper<R> rowMapper) Lazy execution, lazy fetching. No connection fetching/creating, no statement preparing or execution, no result fetching until@TerminalOp
or@TerminalOpTriggered
stream operation is called.- Parameters:
singleSelectPropName
-cond
-rowMapper
-- Returns:
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
forEach
void forEach(com.landawn.abacus.condition.Condition cond, Jdbc.RowConsumer rowConsumer) throws SQLException - Parameters:
cond
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
forEach
void forEach(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowConsumer rowConsumer) throws SQLException - Parameters:
cond
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
forEach
void forEach(com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowConsumer rowConsumer) throws SQLException - Parameters:
cond
-rowFilter
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
forEach
void forEach(com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowConsumer rowConsumer) throws SQLException - Parameters:
cond
-rowFilter
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
forEach
void forEach(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowConsumer rowConsumer) throws SQLException - Parameters:
selectPropNames
-cond
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
forEach
void forEach(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowConsumer rowConsumer) throws SQLException - Parameters:
selectPropNames
-cond
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
forEach
void forEach(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.RowFilter rowFilter, Jdbc.RowConsumer rowConsumer) throws SQLException - Parameters:
selectPropNames
-cond
-rowFilter
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
forEach
void forEach(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Jdbc.BiRowFilter rowFilter, Jdbc.BiRowConsumer rowConsumer) throws SQLException - Parameters:
selectPropNames
-cond
-rowFilter
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
foreach
@Beta default void foreach(Collection<String> selectPropNames, com.landawn.abacus.condition.Condition cond, Consumer<com.landawn.abacus.util.NoCachingNoUpdating.DisposableObjArray> rowConsumer) throws SQLException - Parameters:
selectPropNames
-cond
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
foreach
@Beta default void foreach(com.landawn.abacus.condition.Condition cond, Consumer<com.landawn.abacus.util.NoCachingNoUpdating.DisposableObjArray> rowConsumer) throws SQLException - Parameters:
cond
-rowConsumer
-- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
update
default int update(String propName, Object propValue, com.landawn.abacus.condition.Condition cond) throws SQLException - Parameters:
propName
-propValue
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
update
int update(Map<String, Object> updateProps, com.landawn.abacus.condition.Condition cond) throws SQLExceptionUpdate all the records found by specifiedcond
with all the properties from specifiedupdateProps
.- Parameters:
updateProps
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
update
Update all the records found by specifiedcond
with the properties from specifiedentity
.- Parameters:
entity
-cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
update
int update(T entity, Collection<String> propNamesToUpdate, com.landawn.abacus.condition.Condition cond) throws SQLException Update all the records found by specifiedcond
with specifiedpropNamesToUpdate
from specifiedentity
.- Parameters:
entity
-cond
-propNamesToUpdate
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
upsert
Executeadd
and return the added entity if the record doesn't, otherwise,update
is executed and updated db record is returned.- Parameters:
entity
-cond
- to verify if the record exists or not.- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
delete
- Parameters:
cond
-- Returns:
- Throws:
SQLException
- See Also:
-
ConditionFactory
ConditionFactory.CF
-
asyncCall
@Beta default <R> com.landawn.abacus.util.ContinuableFuture<R> asyncCall(com.landawn.abacus.util.Throwables.Function<TD, R, SQLException> sqlAction) Any transaction started in current thread won't be automatically applied to specifiedsqlAction
which will be executed in another thread.- Type Parameters:
R
-- Parameters:
sqlAction
-- Returns:
-
asyncCall
@Beta default <R> com.landawn.abacus.util.ContinuableFuture<R> asyncCall(com.landawn.abacus.util.Throwables.Function<TD, R, SQLException> sqlAction, Executor executor) Any transaction started in current thread won't be automatically applied to specifiedsqlAction
which will be executed in another thread.- Type Parameters:
R
-- Parameters:
sqlAction
-executor
-- Returns:
-
asyncRun
@Beta default com.landawn.abacus.util.ContinuableFuture<Void> asyncRun(com.landawn.abacus.util.Throwables.Consumer<TD, SQLException> sqlAction) Any transaction started in current thread won't be automatically applied to specifiedsqlAction
which will be executed in another thread.- Parameters:
sqlAction
-- Returns:
-
asyncRun
@Beta default com.landawn.abacus.util.ContinuableFuture<Void> asyncRun(com.landawn.abacus.util.Throwables.Consumer<TD, SQLException> sqlAction, Executor executor) Any transaction started in current thread won't be automatically applied to specifiedsqlAction
which will be executed in another thread.- Parameters:
sqlAction
-executor
-- Returns:
-