Deprecated API
Contents
-
Terminally Deprecated ElementsElementDescriptionInstead, issue an SQL query to retrieve the data using JdbcTemplate and EntityRowMapper
Find all objects.
Instead, issue an SQL query to retrieve the data using JdbcTemplate and EntityRowMapperReturns list of objects which match the property value. 'IS NULL' clause will be used in the sql for a null value.
Instead, issue an SQL query with JdbcTemplate and EntityRowMapper to retrieve the dataReturns list of objects which match the collection of property values. Uses an sql 'IN' clause. Large number of values could cause query performance degradation. Also different databases have different number/size limitations for sql 'IN" clauses.
Query is constructed in such a way that if there is a null value in the propertyValues the returned records will include records which match 'IS NULL' in the database.Instead use getSqlColumns() with EntityRowMapper to retrieve dataGets the sql columns. Works well with Spring row mappers like BeanPropertyRowMapper(), SimplePropertyRowMapper() etc. Will create the needed column aliases where the column name does not match the corresponding underscore case property name.
It is a good practice to store this string, since every time this method is invoked the columns have to be concatenated along with some string manipulation
Will return something like below if 'name' property is mapped to 'last_name' column in database:
"somecolumn, someothercolumn, last_name AS name"Example:String sql = "SELECT " + sjm.getBeanFriendlySqlColumns(Product.class) + " FROM product WHERE product_name = ?";Using Spring's JdbcClient api for the above sql. JdbcClient is using SimplePropertyRowMapper internally here.
Using Spring's JdbcTemplate api for the above sqlList<Product>products = sjm.getJdbcClient().sql(sql).param("someProductName").query(Product.class).list();List<Product>products = sjm.getJdbcTemplate().query(sql, BeanPropertyRowMapper.newInstance(Product.class), "someProductName");Instead use getSqlColumns() with EntityRowMapper to retrieve dataGets the sql columns with columns prefixed with the table alias. Works well with Spring row mappers like BeanPropertyRowMapper(), SimplePropertyRowMapper() etc. Will prefix table column names with the 'tableAlias.' and will create the needed column aliases where the column name does not match the corresponding underscore case property name.
Use it in your custom queries when you are doing joins and need columns corresponding to a table alias.
It is a good practice to store this string, since every time this method is invoked the columns have to be concatenated long with some string manipulation.
For tableAlias argument 't1' will return something like below if 'name' property is mapped to 'last_name' column in database:
"t1.somecolumn, t1.someothercolumn, t1.last_name AS name"Example:String sql = "SELECT " + sjm.getBeanFriendlySqlColumns(Product.class, "t1") + " FROM product t1 WHERE t1.product_name = ?";Using Spring's JdbcClient api for the above sql. JdbcClient is using SimplePropertyRowMapper internally here.
Using Spring's JdbcTemplate api for the above sqlList<Product>products = sjm.getJdbcClient().sql(sql).param("someProductName").query(Product.class).list();List<Product>products = sjm.getJdbcTemplate().query(sql, BeanPropertyRowMapper.newInstance(Product.class), "someProductName");SeeAttributeConverteron how to use custom converters.Exposing the conversion service used, so if necessary new converters can be added etc. The default conversion service used in SimpleJdbcMapper is Spring's DefaultConversionService.
UseSimpleJdbcMapper.getSqlColumns(Class<?> entityType)instead.Gets the sql columns that works with EntityRowMapper. EntityRowMapper expects the sql columns to be in a specific order since it uses position indexes to retrieve the data from the query ResultSet. Do not modify the generated sql columns.
Always use this method (or its overloaded method
SimpleJdbcMapper.getEntitySqlColumns(Class<?> entityType, String tableAlias)) to create your custom query columns when using EntityRowMapper.EntityRowMapperwill handle the column to property mapping."somecolumn, some_other_column, last_name"SeeSimpleJdbcMapper.newEntityRowMapper(java.lang.Class<T>)UseSimpleJdbcMapper.getSqlColumns(Class<?> entityType, String tableAlias)instead.Gets the sql columns with table aliases that works with EntityRowMapper. EntityRowMapper expects the sql columns to be in a specific order since it uses position indexes to retrieve the data from the query ResultSet. Do not modify the generated sql columns.
Always use this method (or its overloaded method
SimpleJdbcMapper.getEntitySqlColumns(Class<?> entityType)) to create your custom query columns when using EntityRowMapper. create your custom query columns when using EntityRowMapper.EntityRowMapperwill handle the column to property mapping.Use it in your custom queries when you are doing joins and need columns corresponding to a table alias.
For tableAlias argument 't1' will return something like below:
"t1.somecolumn, t1.someothercolumn, t1.last_name"Its good practice to keep the table aliases short and succinct. SeeSimpleJdbcMapper.newEntityRowMapper(java.lang.Class<T>)UseSimpleJdbcMapper.getSqlColumns(MultiEntity multiEntity)instead.
Gets the sql columns for multi-entity processing. These sql columns are used with the ResultSetExtractor and should not be modified since the extractor uses position indexes to retrieve the data from the query ResultSet.For the following multi-entity:
new MultiEntity().add(Order.class, "o").add(OrderLine.class, "ol")this will generate sql columns like below:o.id, o.order_date, ol.id, ol.product_id ...Its good practice to keep the table aliases short and succinct. SeeSimpleJdbcMapper.resultSetExtractor(io.github.simplejdbcmapper.core.MultiEntity)UseSimpleJdbcMapper.entityRowMapper(Class)instead.Returns a new EntityRowMapper.
EntityRowMapper always has to be used with sql columns generated by either
SimpleJdbcMapper.getEntitySqlColumns(Class<?> entityType)orSimpleJdbcMapper.getEntitySqlColumns(Class<?> entityType, String tableAlias)It expects the sql columns to be in a specific order because it uses position indexes to retrieve the data from the query ResultSet. It will handle the cases where the column to property mappings do not follow the underscore to camel case naming convention.
This is the recommended row mapper to use when writing custom queries for mapped objects. It has optimizations which allows it to process data from the query ResultSet in a performant way.
Query:
String sql = "SELECT " + sjm.getEntitySqlColumns(Product.class) + "FROM product WHERE name = ?";Example using JdbcTemplate:List<Product>products = sjm.getJdbcTemplate().query(sql,sjm.newEntityRowMapper(Product.class), "someProductName");Example using JdbcClient. Note that the EntityRowMaper has to be passed in as an argument, otherwise JdbcClient will use its internal row mapper SimplePropertyRowMapper which will not work with the sql.
List<Product>products = sjm.getJdbcClient().sql(sql) .param("someProductName") .query(sjm.newEntityRowMapper(Product.class)) .list();SeeAttributeConverteron how to use custom converters.Set the conversion service
Instead, issue an SQL query with ORDER BY clause and retrieve the data using JdbcTemplate and EntityRowMapperThis is used to generate the "ORDER BY" clause for the queries.
-
Deprecated ClassesClassDescriptionInstead, issue an SQL query with ORDER BY clause and retrieve the data using JdbcTemplate and EntityRowMapper
This is used to generate the "ORDER BY" clause for the queries.
-
Deprecated MethodsMethodDescriptionInstead, issue an SQL query to retrieve the data using JdbcTemplate and EntityRowMapper
Find all objects.
Instead, issue an SQL query to retrieve the data using JdbcTemplate and EntityRowMapperReturns list of objects which match the property value. 'IS NULL' clause will be used in the sql for a null value.
Instead, issue an SQL query with JdbcTemplate and EntityRowMapper to retrieve the dataReturns list of objects which match the collection of property values. Uses an sql 'IN' clause. Large number of values could cause query performance degradation. Also different databases have different number/size limitations for sql 'IN" clauses.
Query is constructed in such a way that if there is a null value in the propertyValues the returned records will include records which match 'IS NULL' in the database.Instead use getSqlColumns() with EntityRowMapper to retrieve dataGets the sql columns. Works well with Spring row mappers like BeanPropertyRowMapper(), SimplePropertyRowMapper() etc. Will create the needed column aliases where the column name does not match the corresponding underscore case property name.
It is a good practice to store this string, since every time this method is invoked the columns have to be concatenated along with some string manipulation
Will return something like below if 'name' property is mapped to 'last_name' column in database:
"somecolumn, someothercolumn, last_name AS name"Example:String sql = "SELECT " + sjm.getBeanFriendlySqlColumns(Product.class) + " FROM product WHERE product_name = ?";Using Spring's JdbcClient api for the above sql. JdbcClient is using SimplePropertyRowMapper internally here.
Using Spring's JdbcTemplate api for the above sqlList<Product>products = sjm.getJdbcClient().sql(sql).param("someProductName").query(Product.class).list();List<Product>products = sjm.getJdbcTemplate().query(sql, BeanPropertyRowMapper.newInstance(Product.class), "someProductName");Instead use getSqlColumns() with EntityRowMapper to retrieve dataGets the sql columns with columns prefixed with the table alias. Works well with Spring row mappers like BeanPropertyRowMapper(), SimplePropertyRowMapper() etc. Will prefix table column names with the 'tableAlias.' and will create the needed column aliases where the column name does not match the corresponding underscore case property name.
Use it in your custom queries when you are doing joins and need columns corresponding to a table alias.
It is a good practice to store this string, since every time this method is invoked the columns have to be concatenated long with some string manipulation.
For tableAlias argument 't1' will return something like below if 'name' property is mapped to 'last_name' column in database:
"t1.somecolumn, t1.someothercolumn, t1.last_name AS name"Example:String sql = "SELECT " + sjm.getBeanFriendlySqlColumns(Product.class, "t1") + " FROM product t1 WHERE t1.product_name = ?";Using Spring's JdbcClient api for the above sql. JdbcClient is using SimplePropertyRowMapper internally here.
Using Spring's JdbcTemplate api for the above sqlList<Product>products = sjm.getJdbcClient().sql(sql).param("someProductName").query(Product.class).list();List<Product>products = sjm.getJdbcTemplate().query(sql, BeanPropertyRowMapper.newInstance(Product.class), "someProductName");SeeAttributeConverteron how to use custom converters.Exposing the conversion service used, so if necessary new converters can be added etc. The default conversion service used in SimpleJdbcMapper is Spring's DefaultConversionService.
UseSimpleJdbcMapper.getSqlColumns(Class<?> entityType)instead.Gets the sql columns that works with EntityRowMapper. EntityRowMapper expects the sql columns to be in a specific order since it uses position indexes to retrieve the data from the query ResultSet. Do not modify the generated sql columns.
Always use this method (or its overloaded method
SimpleJdbcMapper.getEntitySqlColumns(Class<?> entityType, String tableAlias)) to create your custom query columns when using EntityRowMapper.EntityRowMapperwill handle the column to property mapping."somecolumn, some_other_column, last_name"SeeSimpleJdbcMapper.newEntityRowMapper(java.lang.Class<T>)UseSimpleJdbcMapper.getSqlColumns(Class<?> entityType, String tableAlias)instead.Gets the sql columns with table aliases that works with EntityRowMapper. EntityRowMapper expects the sql columns to be in a specific order since it uses position indexes to retrieve the data from the query ResultSet. Do not modify the generated sql columns.
Always use this method (or its overloaded method
SimpleJdbcMapper.getEntitySqlColumns(Class<?> entityType)) to create your custom query columns when using EntityRowMapper. create your custom query columns when using EntityRowMapper.EntityRowMapperwill handle the column to property mapping.Use it in your custom queries when you are doing joins and need columns corresponding to a table alias.
For tableAlias argument 't1' will return something like below:
"t1.somecolumn, t1.someothercolumn, t1.last_name"Its good practice to keep the table aliases short and succinct. SeeSimpleJdbcMapper.newEntityRowMapper(java.lang.Class<T>)UseSimpleJdbcMapper.getSqlColumns(MultiEntity multiEntity)instead.
Gets the sql columns for multi-entity processing. These sql columns are used with the ResultSetExtractor and should not be modified since the extractor uses position indexes to retrieve the data from the query ResultSet.For the following multi-entity:
new MultiEntity().add(Order.class, "o").add(OrderLine.class, "ol")this will generate sql columns like below:o.id, o.order_date, ol.id, ol.product_id ...Its good practice to keep the table aliases short and succinct. SeeSimpleJdbcMapper.resultSetExtractor(io.github.simplejdbcmapper.core.MultiEntity)UseSimpleJdbcMapper.entityRowMapper(Class)instead.Returns a new EntityRowMapper.
EntityRowMapper always has to be used with sql columns generated by either
SimpleJdbcMapper.getEntitySqlColumns(Class<?> entityType)orSimpleJdbcMapper.getEntitySqlColumns(Class<?> entityType, String tableAlias)It expects the sql columns to be in a specific order because it uses position indexes to retrieve the data from the query ResultSet. It will handle the cases where the column to property mappings do not follow the underscore to camel case naming convention.
This is the recommended row mapper to use when writing custom queries for mapped objects. It has optimizations which allows it to process data from the query ResultSet in a performant way.
Query:
String sql = "SELECT " + sjm.getEntitySqlColumns(Product.class) + "FROM product WHERE name = ?";Example using JdbcTemplate:List<Product>products = sjm.getJdbcTemplate().query(sql,sjm.newEntityRowMapper(Product.class), "someProductName");Example using JdbcClient. Note that the EntityRowMaper has to be passed in as an argument, otherwise JdbcClient will use its internal row mapper SimplePropertyRowMapper which will not work with the sql.
List<Product>products = sjm.getJdbcClient().sql(sql) .param("someProductName") .query(sjm.newEntityRowMapper(Product.class)) .list();SeeAttributeConverteron how to use custom converters.Set the conversion service