@Repositorybr/>@EnableCaching
class UserDao(jdbcTemplate: JdbcTemplate) {
@Cacheable(keyGenerator = "cacheKeyGenerator", cacheNames = Array("merInfo"))
private def findByName(name: String): Option[User] = {
val sql = "" //此处为sql
val rs = jdbcTemplate.queryForRowSet(sql, name)
if (rs.next()) {
Some(User(
rs.getString("name"),
rs.getString("age")
))
} else None
}
def findUser(name: String): Option[User] = {
findByName(name)
}
}
原文地址:http://blog.51cto.com/8953871/2126063