Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.pig.database.databasedemo.jdbc;
- import java.util.List;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.jdbc.core.BeanPropertyRowMapper; //new!! 來自Spring
- import org.springframework.jdbc.core.JdbcTemplate; //new!! 來自Spirng
- import org.springframework.stereotype.Repository;
- import com.pig.database.databasedemo.entity.Person;
- @Repository
- public class PersonjdbcDao {
- @Autowired
- JdbcTemplate jdbcTemplate;
- //select * from person
- public List<Person> findAll(){
- return jdbcTemplate.query("select * from person",
- new BeanPropertyRowMapper<Person>(Person.class));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement