Deprecated API
Contents
-
Terminally Deprecated ElementsElementDescriptionUse
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
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"SeenewEntityRowMapper(java.lang.Class<T>)UsegetSqlColumns(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
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. SeenewEntityRowMapper(java.lang.Class<T>)UsegetSqlColumns(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. SeeresultSetExtractor(io.github.simplejdbcmapper.core.MultiEntity)UseentityRowMapper(Class)instead.Returns a new EntityRowMapper.
EntityRowMapper always has to be used with sql columns generated by either
getEntitySqlColumns(Class<?> entityType)orgetEntitySqlColumns(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();
-
Deprecated MethodsMethodDescriptionUse
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
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"SeenewEntityRowMapper(java.lang.Class<T>)UsegetSqlColumns(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
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. SeenewEntityRowMapper(java.lang.Class<T>)UsegetSqlColumns(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. SeeresultSetExtractor(io.github.simplejdbcmapper.core.MultiEntity)UseentityRowMapper(Class)instead.Returns a new EntityRowMapper.
EntityRowMapper always has to be used with sql columns generated by either
getEntitySqlColumns(Class<?> entityType)orgetEntitySqlColumns(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();