Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package com.pig.database.databasedemo.jdbc;
  2.  
  3. import java.util.List;
  4.  
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.jdbc.core.BeanPropertyRowMapper; //new!! 來自Spring
  7. import org.springframework.jdbc.core.JdbcTemplate; //new!! 來自Spirng
  8. import org.springframework.stereotype.Repository;
  9.  
  10. import com.pig.database.databasedemo.entity.Person;
  11.  
  12. @Repository
  13. public class PersonjdbcDao {
  14.  
  15. @Autowired
  16. JdbcTemplate jdbcTemplate;
  17.  
  18. //select * from person
  19. public List<Person> findAll(){
  20. return jdbcTemplate.query("select * from person",
  21. new BeanPropertyRowMapper<Person>(Person.class));
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement