SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top