派生自 projectDept/qhighschool

EricsHu
2022-12-05 068fc7f2e81178e55fa191a13709af64b1a163f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/******************************************************************************
 * All Rights Reserved.
 * 本软件为深圳市企鹅网络科技有限公司开发研制。未经本公司正式书面同意,其他任何个人、团体
 * 不得使用、复制、修改或发布本软件.
 *****************************************************************************/
 
package com.qxueyou.scc.org.dao;
 
import java.text.ParseException;
import java.util.List;
 
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
 
import com.qxueyou.scc.org.model.OrgCollegeCourse;
 
 
@Repository(value="orgCourseDAO")
/**
 * 自动注入sessionFactory 
 *
 * @author ody.yuan
 * @since JDK1.6
 * @history 2015-04-23
 */
public class OrgCourseDAO extends HibernateDaoSupport {
    
    /**
     * 注入sessionFactory
     *
     * @param sessionFactory
     */
    @Autowired(required = false)
    public void setSessionfactory(SessionFactory sessionFactory) {
        this.setSessionFactory(sessionFactory);
    }
    
    /**
     * 查询课程列表明细
     * @param sql
     * @param args
     * @return
     * @throws ParseException 
     */
    @SuppressWarnings("unchecked")
    public List<OrgCollegeCourse> queryCourseList(String sql,List<Object> args) {
        // 查询结果
        Session session = this.getSessionFactory().getCurrentSession();
        SQLQuery query = session.createSQLQuery(sql);
        query.setResultTransformer(Transformers.aliasToBean(OrgCollegeCourse.class));
        for(int i = 0;args !=null && i < args.size() ;  i++ ){
            query.setParameter(i, args.get(i));
        }
        List<OrgCollegeCourse> lstItems = query.list();
        
        return lstItems;
    }
    
}