January 2019
Intermediate to advanced
392 pages
10h 11m
English
Find the code snippet pertaining to the read operation. The following function will return a list of all the user's details:
override fun getAllUserList(): List<UserModel> { val selectAllSql = "SELECT * FROM users" return jdbcTemplate.query(selectAllSql, UserRowMapper())}
selectAllSql = "SELECT * FROM users" is the query to fetch all the users from user the table. jdbcTemplate.query() will execute the query and fetch the data.
This following function will get a user's details based on id:
override fun getUserByID(id: Int): UserModel? { val selectAllSql = "SELECT * FROM users WHERE id = ?" return jdbcTemplate.queryForObject(selectAllSql, UserRowMapper(), id)}
selectAllSql = "SELECT * FROM users WHERE id = ?" is the query to fetch a user ...
Read now
Unlock full access