zoukankan      html  css  js  c++  java
  • IBATISNET中的lazyLoad

    使用IBATISNET免不了用到lazyload特性,这样可以实现延迟加载,提高数据库访问效率。但使用lazyload的时候要小心,别忘了给需要lazyload的属性加上virtual关键字哦,不然的话无法实现延迟加载的(我发现在单步调试的时候反而可以延迟加载)。

    映射文件:

        <resultMap id="ApplicationResult" class="Application">
          
    <result property="Id" column="id" dbType="guid"/>
          
    <result property="YearNum" column="yearnum"/>

          
    <result property="Budget.XMLValue" column="budget"/>
          
    <result property="StudentInfo" column='id' select="Application.SelectStudentInfo" lazyLoad="true"/>
          
    <result property="TeacherInfo" column="id" select="Application.SelectTeacherInfo" lazyLoad="true"/>

        
    </resultMap>

    对应的Model

        [Serializable]
        
    public class Application
        {
            
    #region Model
            
    private Guid _id = Guid.Empty;

            
    private IList<StudentInfo> _students = new List<StudentInfo>(0);
            
    private IList<TeacherInfo> _teachers = new List<TeacherInfo>(0);

            
    public Application()
            { }

            
    public Guid Id
            {
                
    set { _id = value; }
                
    get { return _id; }
            }

            
    public virtual IList<StudentInfo> StudentInfo
            {
                
    get { return _students; }
                
    set { _students = value; }
            }

            
    public virtual IList<TeacherInfo> TeacherInfo
            {
                
    get { return _teachers; }
                
    set { _teachers = value; }
            }

    }
  • 相关阅读:
    freemarker list集合去重,实现hashset
    freemarker特殊字符输出
    idea java 注释模板配置
    IntelliJ IDEA使用eclipse compiler(ecj)解决lombok编译问题
    odoo views
    python 内置函数 3.6版本
    iostat
    性能及优化之 vmstat
    python 基础
    git
  • 原文地址:https://www.cnblogs.com/xwing/p/1299616.html
Copyright © 2011-2022 走看看