我想在获取方法之一中调用onload拦截器方法,因为查询是带有联接的SELECT QUERY

时间:2019-01-22 10:32:44

标签: spring hibernate interceptor

我有一个使用SELECT QUERY的get方法,因为我从两个表中都选择了很少的列,并且我为此绑定了参数,所以我为变量定位创建了一个bean

我已经创建了一个拦截器接口,并且在获取方法的会话中包含了该拦截器

公共列表getVendorList(String bUnit,long seq){

    StringBuilder sql = new StringBuilder(2048);
    sql.append("SELECT DISTINCT GDMV.VENDOR_PK,GDMV.seq,GDMV.SUPPLIER,GDMV.SITE_CODE ,GDMV.BUSINESS_UNIT,GDMV.WHO_MODIFIED,GDMV.DATE_MODIFIED,GDMV.D_UNIT,GV.V_NAME,GV.SR_CATEGORY,GV.V_TYPE  FROM VENDOR GDMV,G_VENDOR GV WHERE GDMV.SUPPLIER=GV.V_NUMBER AND GDMV.seq=:seqAND GDMV.D_UNIT=:D_UNIT ");

    //Session session = sessionFactory.getCurrentSession();
    Session session = sessionFactory.withOptions().interceptor(new DmInterceptor()).openSession();

    Query  nativequerySQLQuery = session.createSQLQuery(sql.toString());
    List<VendorRelationRequestDTO> result = new ArrayList<>();
    nativequerySQLQuery.setParameter("seq", seq);
    nativequerySQLQuery.setParameter("D_UNIT", Unit);
    List<Object[]> resultList = nativequerySQLQuery.list();
    for (Object[] element : resultList) {
        VendorRelationRequestDTO record = new VendorRelationRequestDTO(element);
        result.add(record);
    }
    return result;
}

当调用此“ getVendorList” ONLOAD方法时,应在控制台中执行,它应在控制台中打印,例如“加载操作完成”

0 个答案:

没有答案