Package com.landawn.abacus.jdbc
Class NamedQuery
java.lang.Object
com.landawn.abacus.jdbc.AbstractPreparedQuery<PreparedStatement,NamedQuery>
com.landawn.abacus.jdbc.NamedQuery
- All Implemented Interfaces:
Closeable
,AutoCloseable
The backed
Generally, don't cache or reuse the instance of this class, except the
The
Remember: parameter/column index in
PreparedStatement/CallableStatement
will be closed by default
after any execution methods(which will trigger the backed PreparedStatement/CallableStatement
to be executed, for example: get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/...).
except the 'closeAfterExecution'
flag is set to false
by calling #closeAfterExecution(false)
.
Generally, don't cache or reuse the instance of this class, except the
'closeAfterExecution'
flag is set to false
by calling #closeAfterExecution(false)
.
The
ResultSet
returned by query will always be closed after execution, even 'closeAfterExecution'
flag is set to false
.
Remember: parameter/column index in
PreparedStatement/ResultSet
starts from 1, not 0.-
Method Summary
Modifier and TypeMethodDescription<T> NamedQuery
addBatchParameters
(Collection<? extends T> batchParameters) setAsciiStream
(String parameterName, InputStream x) Sets the ascii stream.setAsciiStream
(String parameterName, InputStream x, long length) Sets the ascii stream.setBigDecimal
(String parameterName, BigDecimal x) Sets the big decimal.setBigDecimal
(String parameterName, BigInteger x) setBigIntegerAsString
(String parameterName, BigInteger x) Sets the BigInteger.setBinaryStream
(String parameterName, InputStream x) Sets the binary stream.setBinaryStream
(String parameterName, InputStream x, long length) Sets the binary stream.setBlob
(String parameterName, InputStream x) Sets the blob.setBlob
(String parameterName, InputStream x, long length) Sets the blob.Sets the blob.setBoolean
(String parameterName, boolean x) Sets the boolean.setBoolean
(String parameterName, Boolean x) Sets the boolean.Sets the byte.Sets the byte.Sets the bytes.setCharacterStream
(String parameterName, Reader x) Sets the character stream.setCharacterStream
(String parameterName, Reader x, long length) Sets the character stream.Sets the clob.Sets the clob.Sets the clob.Sets the date.Sets the date.Sets the double.Sets the double.Sets the float.Sets the float.Deprecated.Sets the int.Deprecated.generallychar
should be saved asString
in db.Sets the int.Sets the long.Sets the long.setLong
(String parameterName, BigInteger x) Sets the long.setNCharacterStream
(String parameterName, Reader x) Sets the N character stream.setNCharacterStream
(String parameterName, Reader x, long length) Sets the N character stream.Sets the N clob.Sets the N clob.Sets the N clob.setNString
(String parameterName, String x) Sets the string.Sets the null.Sets the null.Sets the object.Sets the object.Sets the object.Sets the object.Sets the object.Sets the object.setParameters
(Object parameters) Sets the parameters.setParameters
(Object entity, Collection<String> parameterNames) Sets the parameters.setParameters
(Map<String, ?> parameters) Sets the parameters.<T> NamedQuery
setParameters
(T paramaters, Jdbc.TriParametersSetter<? super NamedQuery, ? super T> paramsSetter) Sets the parameters.Sets the short.Sets the short.setString
(String parameterName, CharSequence x) Sets the string.setString
(String parameterName, BigInteger x) Sets the time.Sets the time.setTimestamp
(String parameterName, Timestamp x) Sets the timestamp.setTimestamp
(String parameterName, Date x) Sets the timestamp.Methods inherited from class com.landawn.abacus.jdbc.AbstractPreparedQuery
addBatch, addBatchParameters, addBatchParameters, addBatchParameters, addBatchParameters, addBatchParameters, addBatchParameters, addBatchParameters, allMatch, allMatch, anyMatch, anyMatch, asyncCall, asyncCall, asyncRun, asyncRun, batchInsert, batchInsert, batchInsert, batchUpdate, batchUpdateAndReturnGeneratedKeys, batchUpdateAndReturnGeneratedKeys, close, closeAfterExecution, configStmt, configStmt, count, count, count, execute, executeThenAccept, executeThenAccept, executeThenApply, executeThenApply, exists, findFirst, findFirst, findFirst, findFirst, findFirst, findFirst, findFirstOrNull, findFirstOrNull, findFirstOrNull, findFirstOrNull, findFirstOrNull, findFirstOrNull, findOnlyOne, findOnlyOne, findOnlyOne, findOnlyOne, findOnlyOneOrNull, findOnlyOneOrNull, findOnlyOneOrNull, findOnlyOneOrNull, foreach, foreach, forEach, forEach, forEach, forEach, ifExists, ifExists, ifExistsOrElse, ifExistsOrElse, insert, insert, insert, largeBatchUpdate, largeUpdate, list, list, list, list, list, list, list, list, list, list, list, listThenApply, listThenApply, listThenApply, noneMatch, noneMatch, notExists, onClose, query, query, query, query, queryForBigDecimal, queryForBigInteger, queryForBoolean, queryForByte, queryForBytes, queryForChar, queryForDate, queryForDouble, queryForFloat, queryForInt, queryForLong, queryForShort, queryForSingleNonNull, queryForSingleNonNull, queryForSingleResult, queryForSingleResult, queryForString, queryForTime, queryForTimestamp, queryForUniqueNonNull, queryForUniqueNonNull, queryForUniqueResult, queryForUniqueResult, queryThenAccept, queryThenAccept, queryThenApply, queryThenApply, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setBigDecimal, setBigDecimal, setBigIntegerAsString, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setBlob, setBoolean, setBoolean, setBooleanForMultiPositions, setByte, setByte, setBytes, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setClob, setClob, setDate, setDate, setDate, setDateForMultiPositions, setDateForMultiPositions, setDouble, setDouble, setDoubleForMultiPositions, setDoubleForMultiPositions, setFetchDirection, setFetchDirectionToForward, setFetchSize, setFloat, setFloat, setInt, setInt, setInt, setInt, setIntegerForMultiPositions, setIntForMultiPositions, setLargeMaxRows, setLong, setLong, setLong, setLongForMultiPositions, setLongForMultiPositions, setMaxFieldSize, setMaxRows, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setNString, setNull, setNull, setNullForMultiPositions, setObject, setObject, setObject, setObject, setObject, setObject, setObjectForMultiPositions, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setParameters, setQueryTimeout, setRef, setRowId, setShort, setShort, setSQLXML, setString, setString, setString, setString, setString, setStringForMultiPositions, setTime, setTime, setTime, setTimeForMultiPositions, setTimeForMultiPositions, setTimestamp, setTimestamp, setTimestamp, setTimestampForMultiPositions, setTimestampForMultiPositions, settParameters, settParameters, settParameters, settParameters, settParameters, settParameters, settParameters, settParameters, setURL, stream, stream, stream, stream, stream, stream, update, updateAndReturnGeneratedKeys, updateAndReturnGeneratedKeys
-
Method Details
-
setNull
Sets the null.- Parameters:
parameterName
-sqlType
-- Returns:
- Throws:
SQLException
- the SQL exception- See Also:
-
setNull
Sets the null.- Parameters:
parameterName
-sqlType
-typeName
-- Returns:
- Throws:
SQLException
- the SQL exception- See Also:
-
setBoolean
Sets the boolean.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setBoolean
Sets the boolean.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setByte
Sets the byte.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setByte
Sets the byte.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setShort
Sets the short.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setShort
Sets the short.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setInt
Sets the int.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setInt
Sets the int.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setInt
Deprecated.generallychar
should be saved asString
in db.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- See Also:
-
setInt
Deprecated.generallychar
should be saved asString
in db.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- See Also:
-
setLong
Sets the long.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setLong
Sets the long.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setLong
Sets the long.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setFloat
Sets the float.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setFloat
Sets the float.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setDouble
Sets the double.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setDouble
Sets the double.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setBigDecimal
Sets the big decimal.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setBigDecimal
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
-
setBigIntegerAsString
@Beta public NamedQuery setBigIntegerAsString(String parameterName, BigInteger x) throws SQLException Sets the BigInteger.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
-
setString
Sets the string.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setString
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
-
setString
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
-
setString
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
-
setString
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
-
setNString
Sets the string.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setDate
Sets the date.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setDate
Sets the date.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setTime
Sets the time.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setTime
Sets the time.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setTimestamp
Sets the timestamp.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setTimestamp
Sets the timestamp.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setBytes
Sets the bytes.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setAsciiStream
Sets the ascii stream.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setAsciiStream
public NamedQuery setAsciiStream(String parameterName, InputStream x, long length) throws SQLException Sets the ascii stream.- Parameters:
parameterName
-x
-length
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setBinaryStream
Sets the binary stream.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setBinaryStream
public NamedQuery setBinaryStream(String parameterName, InputStream x, long length) throws SQLException Sets the binary stream.- Parameters:
parameterName
-x
-length
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setCharacterStream
Sets the character stream.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setCharacterStream
public NamedQuery setCharacterStream(String parameterName, Reader x, long length) throws SQLException Sets the character stream.- Parameters:
parameterName
-x
-length
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setNCharacterStream
Sets the N character stream.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setNCharacterStream
public NamedQuery setNCharacterStream(String parameterName, Reader x, long length) throws SQLException Sets the N character stream.- Parameters:
parameterName
-x
-length
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setBlob
Sets the blob.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setBlob
Sets the blob.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setBlob
Sets the blob.- Parameters:
parameterName
-x
-length
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setClob
Sets the clob.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setClob
Sets the clob.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setClob
Sets the clob.- Parameters:
parameterName
-x
-length
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setNClob
Sets the N clob.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setNClob
Sets the N clob.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setNClob
Sets the N clob.- Parameters:
parameterName
-x
-length
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setURL
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setSQLXML
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setRowId
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setRef
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setArray
- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setObject
Sets the object.- Parameters:
parameterName
-x
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setObject
Sets the object.- Parameters:
parameterName
-x
-sqlType
-- Returns:
- Throws:
SQLException
- the SQL exception- See Also:
-
setObject
public NamedQuery setObject(String parameterName, Object x, int sqlType, int scaleOrLength) throws SQLException Sets the object.- Parameters:
parameterName
-x
-sqlType
-scaleOrLength
-- Returns:
- Throws:
SQLException
- the SQL exception- See Also:
-
setObject
Sets the object.- Parameters:
parameterName
-x
-sqlType
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setObject
public NamedQuery setObject(String parameterName, Object x, SQLType sqlType, int scaleOrLength) throws SQLException Sets the object.- Parameters:
parameterName
-x
-sqlType
-scaleOrLength
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setObject
public NamedQuery setObject(String parameterName, Object x, com.landawn.abacus.type.Type<Object> type) throws SQLException Sets the object.- Parameters:
parameterName
-x
-type
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setParameters
Sets the parameters.- Parameters:
parameters
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setParameters
Sets the parameters.- Parameters:
parameters
- with getter/setter methods- Returns:
- Throws:
SQLException
- the SQL exception
-
setParameters
public NamedQuery setParameters(Object entity, Collection<String> parameterNames) throws SQLException Sets the parameters.- Parameters:
entity
-parameterNames
-- Returns:
- Throws:
SQLException
- the SQL exception
-
setParameters
public <T> NamedQuery setParameters(T paramaters, Jdbc.TriParametersSetter<? super NamedQuery, ? super T> paramsSetter) throws SQLExceptionSets the parameters.- Type Parameters:
T
-- Parameters:
paramaters
-paramsSetter
-- Returns:
- Throws:
SQLException
- the SQL exception
-
addBatchParameters
public <T> NamedQuery addBatchParameters(Collection<? extends T> batchParameters) throws SQLException - Overrides:
addBatchParameters
in classAbstractPreparedQuery<PreparedStatement,
NamedQuery> - Type Parameters:
T
-- Parameters:
batchParameters
-- Returns:
- Throws:
SQLException
-
char
should be saved asString
in db.