View Javadoc
1   /*
2    *    Copyright 2015-2022 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.mybatis.scripting.freemarker;
17  
18  import java.util.List;
19  
20  import org.apache.ibatis.annotations.Lang;
21  import org.apache.ibatis.annotations.Param;
22  import org.apache.ibatis.annotations.Select;
23  
24  /**
25   * This mapper demonstrates the usage of auto-generating prepared statement parameters instead of usual inline strategy.
26   *
27   * @author elwood
28   */
29  public interface PreparedParamsMapper {
30    @Lang(FreeMarkerLanguageDriver.class)
31    @Select("preparedIn.ftl")
32    List<Name> findByNames(@Param("ids") List<String> ids);
33  
34    /**
35     * This is doesn't work - because params objects are unsupported when using auto-generated prepared parameters (it is
36     * impossible to add parameters to MyBatis engine). This call will throw exception.
37     */
38    @Lang(FreeMarkerLanguageDriver.class)
39    @Select("prepared.ftl")
40    Name findUsingParamsObject(PreparedParam param);
41  
42    @Lang(FreeMarkerLanguageDriver.class)
43    @Select("prepared.ftl")
44    Name findUsingParams(@Param("innerObject") PreparedParam.InnerClass innerClass);
45  }