View Javadoc
1   /**
2    *    Copyright 2006-2016 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    *       http://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.generator.codegen.ibatis2.dao.templates;
17  
18  import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
19  import org.mybatis.generator.api.dom.java.JavaVisibility;
20  import org.mybatis.generator.api.dom.java.Method;
21  
22  /**
23   * @author Jeff Butler
24   */
25  public class SpringDAOTemplate extends AbstractDAOTemplate {
26  
27      /**
28       *  
29       */
30      public SpringDAOTemplate() {
31          super();
32      }
33  
34      @Override
35      protected void configureConstructorTemplate() {
36          Method method = new Method();
37          method.setConstructor(true);
38          method.setVisibility(JavaVisibility.PUBLIC);
39          method.addBodyLine("super();"); //$NON-NLS-1$
40          setConstructorTemplate(method);
41      }
42  
43      @Override
44      protected void configureDeleteMethodTemplate() {
45          setDeleteMethodTemplate("getSqlMapClientTemplate().delete(\"{0}.{1}\", {2});"); //$NON-NLS-1$
46      }
47  
48      @Override
49      protected void configureInsertMethodTemplate() {
50          setInsertMethodTemplate("getSqlMapClientTemplate().insert(\"{0}.{1}\", {2});"); //$NON-NLS-1$
51      }
52  
53      @Override
54      protected void configureQueryForListMethodTemplate() {
55          setQueryForListMethodTemplate("getSqlMapClientTemplate().queryForList(\"{0}.{1}\", {2});"); //$NON-NLS-1$
56      }
57  
58      @Override
59      protected void configureQueryForObjectMethodTemplate() {
60          setQueryForObjectMethodTemplate("getSqlMapClientTemplate().queryForObject(\"{0}.{1}\", {2});"); //$NON-NLS-1$
61      }
62  
63      @Override
64      protected void configureSuperClass() {
65          setSuperClass(new FullyQualifiedJavaType(
66                  "org.springframework.orm.ibatis.support.SqlMapClientDaoSupport")); //$NON-NLS-1$
67      }
68  
69      @Override
70      protected void configureUpdateMethodTemplate() {
71          setUpdateMethodTemplate("getSqlMapClientTemplate().update(\"{0}.{1}\", {2});"); //$NON-NLS-1$
72      }
73  }