- , : " , - ,
RowMapper, ResultSet , .
http://simpleflatmapper.org, ResultSet POJO .
, , , , .
Checkout
http://simpleflatmapper.org/0104-getting-started-springjdbc.html
as well as
https://arnaudroger.imtqy.com/blog/2017/02/27/jooq-one-to-many.html
you will need to get a ResutlSetExtractor - it is thread safe, so only one instance is needed -,
private final ResultSetExtractor<List<Account>> mapper =
JdbcTemplateMapperFactory
.newInstance()
.addKeys("id")
.newResultSetExtractor(Account.class);
String query =
"SELECT ac.id as id, ac.username, ad.id as adverts_id, ad.text as adverts_text"
+ "FROM account ac LEFT OUTER JOIN advert ad ON ad.account_id = ac.id order by id "
List<Account> results = template.query(query, mapper);
so that you should get a list of accounts in the list of filled ads. but the ad does not have an account.
source
share