zoukankan      html  css  js  c++  java
  • 在一个DaoImpl实现中调用另一个DaoImpl中的方法

    1、被调用的Dao接口

    public interface IFieldDescriptionDao {
        public List<String> getFieldDescription(Connection conn,String tableName)throws SQLException; 
    }

    2、被调用的DaoImpl实现

    public class FieldDescriptionDaoImpl implements IFieldDescriptionDao{
        
        public List<String> getFieldDescription(Connection conn,String tableName)throws SQLException{//获取字段的中文说明,作为标题行在页面展示
            return fieldsList;
        }
    }

    3、调用的DaoImpl实现

    import com.dao.IFieldDescriptionDao;

    public class CommunicationStatDaoImpl implements ICommunicationStatDao{

      private  IFieldDescriptionDao fieldDescriptionDao;  //声明另一个Dao字段说明

      public List<List<String>> queryCommunicationList(Connection conn, int pageSize, int currPage) throws SQLException {
           
              List<List<String>> list = new ArrayList<List<String>>();
         
              list.add(fieldDescriptionDao.getFieldDescription(conn,"JT_CommunicationStatus"));//调用方法

        return list;
        }

      //要生成Get/Set方法,要不实例对象为空

      public IFieldDescriptionDao getFieldDescriptionDao() { //get方法
            return fieldDescriptionDao;
         }

        public void setFieldDescriptionDao(IFieldDescriptionDao fieldDescriptionDao) { //set方法
            this.fieldDescriptionDao = fieldDescriptionDao;
        }

    }

    4、在调用的配置文件中,

    <bean name="communicationDao" class="com.chatone.dao.CommunicationStatDaoImpl">
        <property name="fieldDescriptionDao" ref="fieldDescriptionDao"/>  //被调用实例属性
    </bean>


         

  • 相关阅读:
    009-Python-面向对象
    008-Python-模块
    007-Python函数-装饰器
    006-Python函数
    005-Python字典
    003-python列表
    PyCharm之python书写规范--消去提示波浪线
    001-python基础
    Java基础总结(一)
    High ASCII字符从bat文件到dos控制台的转化问题
  • 原文地址:https://www.cnblogs.com/limeiky/p/12512102.html
Copyright © 2011-2022 走看看