youyixiao / rapid-framework

Automatically exported from code.google.com/p/rapid-framework
0 stars 0 forks source link

ibatis3 dao 模板 更具唯一属性来查询对象问题 #40

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
<#list table.columns as column>
    <#if column.unique && !column.pk>
    public ${className} getBy${column.columnName}(${column.javaType} v) {
        return
(${className})getSqlSession().selectOne("${className}.getByUsername",v);
    }   
    </#if>
    </#list>

以上为模板源程序 

我觉得是不是应改为:

<#list table.columns as column>
    <#if column.unique && !column.pk>
    public ${className} getBy${column.columnName}(${column.javaType} v) {
        return
(${className})getSqlSessionTemplate().selectOne("${className}.getBy${column.colu
mnName}",v);
    }   
    </#if>
    </#list>

修改:getSqlSession()--》getSqlSessionTemplate()
      getByUsername--》getBy${column.columnName}

例如:
public UserLoginSession getByUserid(java.lang.String v) {

        //return
(UserLoginSession)getSqlSession().selectOne("UserLoginSession.getByUsername",v);
        // The method getSqlSession() is undefined for the type UserLoginSessionDao
        return
(UserLoginSession)getSqlSessionTemplate().selectOne("UserLoginSession.getByUseri
d",v);
    }

Original issue reported on code.google.com by zgw06...@gmail.com on 26 Feb 2010 at 7:44

GoogleCodeExporter commented 9 years ago
十分感谢,已经修正

Original comment by bad...@gmail.com on 26 Feb 2010 at 1:36