Class JdbcQuery
java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.jdbc.JdbcQuery
- All Implemented Interfaces:
DataExceptionContributor,JsonSerializable,RecordSerializable,XmlSerializable,JdbcSource,Serializable
A named SQL query with its parameters and result columns;
JdbcConnection.loadQueries() fills in the columns by running it.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhether a query returns many rows or a single row; generated DAO code reads only the first row forONE. -
Field Summary
Fields inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
SERIALIZED_CLASS_NAME, TYPEFields inherited from interface com.northconcepts.datapipeline.core.XmlSerializable
XML_SERIALIZED_CLASS_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddColumn(JdbcQueryColumn column) addParameter(JdbcQueryParameter parameter) Adds a parameter for the next?placeholder in the query.addParameter(String name, Class<?> javaType, Integer sqlType, String exampleValueExpression) Adds a parameter for the next?placeholder;sqlTypeis ajava.sql.Typescode or null.addParameter(String name, Class<?> javaType, String exampleValueExpression) Adds a parameter for the next?placeholder with no SQL type, letting the driver infer it.fromRecord(Record source) Loads this instance's state from a record and returnsthis(for fluid API call chaining).Returns whether the query returns many rows or one (default isJdbcQuery.Cardinality.MANY).Returns the result columns, as filled byJdbcConnection.loadQueries().Returns the connection this query was added to, or null.getName()Returns the parameters, in the order of the query's?placeholders.getQuery()Returns the SQL that selects this source's rows.setCardinality(JdbcQuery.Cardinality cardinality) Sets whether the query returns many rows or one; null meansJdbcQuery.Cardinality.MANY.setColumns(Collection<JdbcQueryColumn> columns) Replaces the result columns; null clears them.protected JdbcQuerysetConnection(JdbcConnection connection) Sets the connection this query belongs to; called byJdbcConnection.addQuery(JdbcQuery).setParameters(Collection<JdbcQueryParameter> parameters) Replaces the parameters, given in the order of the query's?placeholders; null clears them.Sorts the result columns by name, ignoring case.toRecord()Converts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.Methods inherited from class com.northconcepts.datapipeline.foundations.core.Bean
addExceptionProperties, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.northconcepts.datapipeline.core.DataExceptionContributor
addExceptionProperties, exception, exception, exceptionMethods inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
fromJson, fromJson, toJson, toJson, toJsonMethods inherited from interface com.northconcepts.datapipeline.core.XmlSerializable
fromXml, fromXml, fromXmlElement, toXml, toXml, toXml, toXml, toXml, toXmlElement
-
Constructor Details
-
JdbcQuery
public JdbcQuery() -
JdbcQuery
-
-
Method Details
-
getConnection
Returns the connection this query was added to, or null. -
setConnection
Sets the connection this query belongs to; called byJdbcConnection.addQuery(JdbcQuery). -
getName
- Specified by:
getNamein interfaceJdbcSource
-
setName
-
getQuery
Description copied from interface:JdbcSourceReturns the SQL that selects this source's rows.- Specified by:
getQueryin interfaceJdbcSource
-
setQuery
-
getParameters
Returns the parameters, in the order of the query's?placeholders. -
setParameters
Replaces the parameters, given in the order of the query's?placeholders; null clears them. -
addParameter
Adds a parameter for the next?placeholder in the query. -
addParameter
public JdbcQuery addParameter(String name, Class<?> javaType, Integer sqlType, String exampleValueExpression) Adds a parameter for the next?placeholder;sqlTypeis ajava.sql.Typescode or null. -
addParameter
Adds a parameter for the next?placeholder with no SQL type, letting the driver infer it. -
getColumns
Returns the result columns, as filled byJdbcConnection.loadQueries(). -
setColumns
Replaces the result columns; null clears them. -
addColumn
-
getCardinality
Returns whether the query returns many rows or one (default isJdbcQuery.Cardinality.MANY). -
setCardinality
Sets whether the query returns many rows or one; null meansJdbcQuery.Cardinality.MANY. -
getSourceType
- Specified by:
getSourceTypein interfaceJdbcSource
-
sortColumns
Sorts the result columns by name, ignoring case. -
toRecord
Description copied from interface:RecordSerializableConverts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.- Specified by:
toRecordin interfaceRecordSerializable- Overrides:
toRecordin classBean
-
fromRecord
Description copied from interface:RecordSerializableLoads this instance's state from a record and returnsthis(for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.- Specified by:
fromRecordin interfaceRecordSerializable- Overrides:
fromRecordin classBean- Parameters:
source-- Returns:
- this instance.
-