|
9 | 9 | import java.util.List; |
10 | 10 | import java.util.Map; |
11 | 11 |
|
12 | | - |
13 | 12 | public interface PersonMapper { |
14 | 13 |
|
15 | | - @Insert("Insert into person(name) values (#{name})") |
16 | | - public Integer save(Person person); |
17 | | - |
18 | | - @Update("Update Person set name= #{name} where personId=#{personId}") |
19 | | - public void updatePerson(Person person); |
| 14 | + @Insert("Insert into person(name) values (#{name})") |
| 15 | + public Integer save(Person person); |
20 | 16 |
|
21 | | - @Delete("Delete from Person where personId=#{personId}") |
22 | | - public void deletePersonById(Integer personId); |
| 17 | + @Update("Update Person set name= #{name} where personId=#{personId}") |
| 18 | + public void updatePerson(Person person); |
23 | 19 |
|
24 | | - @Select("SELECT person.personId, person.name FROM person WHERE person.personId = #{personId}") |
25 | | - Person getPerson(Integer personId); |
| 20 | + @Delete("Delete from Person where personId=#{personId}") |
| 21 | + public void deletePersonById(Integer personId); |
26 | 22 |
|
27 | | - @Select("Select personId,name from Person where personId=#{personId}") |
28 | | - @Results(value ={ |
29 | | - @Result(property = "personId", column = "personId"), |
30 | | - @Result(property="name", column = "name"), |
31 | | - @Result(property = "addresses",javaType = List.class,column = "personId", |
32 | | - many=@Many(select = "getAddresses")) |
| 23 | + @Select("SELECT person.personId, person.name FROM person WHERE person.personId = #{personId}") |
| 24 | + Person getPerson(Integer personId); |
33 | 25 |
|
34 | | - }) |
35 | | - public Person getPersonById(Integer personId); |
| 26 | + @Select("Select personId,name from Person where personId=#{personId}") |
| 27 | + @Results(value = { @Result(property = "personId", column = "personId"), @Result(property = "name", column = "name"), |
| 28 | + @Result(property = "addresses", javaType = List.class, column = "personId", many = @Many(select = "getAddresses")) |
36 | 29 |
|
37 | | - @Select("select addressId,streetAddress,personId from address where personId=#{personId}") |
38 | | - public Address getAddresses(Integer personId); |
| 30 | + }) |
| 31 | + public Person getPersonById(Integer personId); |
39 | 32 |
|
40 | | - @Select("select * from Person ") |
41 | | - @MapKey("personId") |
42 | | - Map<Integer,Person> getAllPerson(); |
| 33 | + @Select("select addressId,streetAddress,personId from address where personId=#{personId}") |
| 34 | + public Address getAddresses(Integer personId); |
43 | 35 |
|
44 | | - @SelectProvider(type=MyBatisUtil.class,method="getPersonByName") |
45 | | - public Person getPersonByName(String name); |
| 36 | + @Select("select * from Person ") |
| 37 | + @MapKey("personId") |
| 38 | + Map<Integer, Person> getAllPerson(); |
46 | 39 |
|
| 40 | + @SelectProvider(type = MyBatisUtil.class, method = "getPersonByName") |
| 41 | + public Person getPersonByName(String name); |
47 | 42 |
|
48 | | - @Select(value= "{ CALL getPersonByProc( #{personId, mode=IN, jdbcType=INTEGER})}") |
49 | | - @Options(statementType = StatementType.CALLABLE) |
50 | | - public Person getPersonByProc(Integer personId); |
| 43 | + @Select(value = "{ CALL getPersonByProc( #{personId, mode=IN, jdbcType=INTEGER})}") |
| 44 | + @Options(statementType = StatementType.CALLABLE) |
| 45 | + public Person getPersonByProc(Integer personId); |
51 | 46 |
|
52 | 47 | } |
0 commit comments