1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.submitted.complex_column;
17
18 import org.apache.ibatis.annotations.*;
19
20 public interface PersonMapper {
21
22 Person getWithoutComplex(Long id);
23 Person getWithComplex(Long id);
24 Person getParentWithComplex(Person person);
25
26 @Select({
27 "SELECT id, firstName, lastName, parent_id, parent_firstName, parent_lastName",
28 "FROM Person",
29 "WHERE id = #{id,jdbcType=INTEGER}"
30 })
31 @ResultMap("personMapComplex")
32 Person getWithComplex2(Long id);
33
34 @Select({
35 "SELECT id, firstName, lastName, parent_id, parent_firstName, parent_lastName",
36 "FROM Person",
37 "WHERE id = #{id,jdbcType=INTEGER}"
38 })
39 @ResultMap("org.apache.ibatis.submitted.complex_column.PersonMapper.personMapComplex")
40 Person getWithComplex3(Long id);
41
42
43 @Select({
44 "SELECT id, firstName, lastName, parent_id, parent_firstName, parent_lastName",
45 "FROM Person",
46 "WHERE id = #{id,jdbcType=INTEGER}"
47 })
48 @Results({
49 @Result(id=true, column = "id", property = "id"),
50 @Result(property = "parent", column="{firstName=parent_firstName,lastName=parent_lastName}", one=@One(select="getParentWithParamAttributes"))
51
52 })
53 Person getComplexWithParamAttributes(Long id);
54
55 @Select("SELECT id, firstName, lastName, parent_id, parent_firstName, parent_lastName" +
56 " FROM Person" +
57 " WHERE firstName = #{firstName,jdbcType=VARCHAR}" +
58 " AND lastName = #{lastName,jdbcType=VARCHAR}" +
59 " LIMIT 1")
60 Person getParentWithParamAttributes(@Param("firstName") String firstName, @Param("lastName") String lastname);
61 }