View Javadoc
1   /*
2    *    Copyright 2009-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.submitted.record_type;
17  
18  import org.apache.ibatis.annotations.Arg;
19  import org.apache.ibatis.annotations.Insert;
20  import org.apache.ibatis.annotations.Results;
21  import org.apache.ibatis.annotations.Select;
22  
23  public interface RecordTypeMapper {
24  
25    @Select("select id, val, url from prop where id = #{id}")
26    Property selectPropertyAutomapping(int id);
27  
28    @Results(id = "propertyRM")
29    @Arg(column = "id", javaType = int.class)
30    @Arg(column = "val", javaType = String.class)
31    @Arg(column = "url", javaType = String.class)
32    @Select("select val, id, url from prop where id = #{id}")
33    Property selectProperty(int id);
34  
35    @Insert("insert into prop (id, val, url) values (#{id}, #{value}, #{URL})")
36    int insertProperty(Property property);
37  
38    @Arg(id = true, column = "id", javaType = Integer.class)
39    @Arg(javaType = Property.class, resultMap = "propertyRM", columnPrefix = "p_")
40    // @formatter:off
41    @Select({
42        "select i.id, p.id p_id, p.val p_val, p.url p_url",
43        "from item i left join prop p on p.id = i.prop_id",
44        "where i.id = #{id}"})
45    // @formatter:on
46    Item selectItem(Integer id);
47  
48  }