繁体   English   中英

无法投放DAO类

[英]DAO class cannot be cast

我有CourseDetailsDAO和BeanDAO。 我越来越

university.BeanDAO cannot be cast to university.CourseDetailsDAO
    at CourseDetailsBean.performLookup(CourseDetailsBean.java:49)
    at CourseDetailsBean.CoursedetailsAction(CourseDetailsBean.java:38) 

这些行是:

CourseDetailsBean.java:49
CourseDetailsDAO helper = (CourseDetailsDAO) apc.getBean("courseDetailsDao");

CourseDetailsBean.java:38
performLookup(cID, cName, cDuration, cEligibility, cFee);

豆豆

public List getStudent() {
List<Student> students = null;
    try
        {
            Session session = sessionFactory.openSession();
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from university.Student");
            students = (List<Student>)q.list();  

课程详情

public List getcourseByName(String courseName) {
    List<Coursedetails> courselist = null;
    try
    {
        Session session = sessionFactory.openSession();
        org.hibernate.Transaction tx = session.beginTransaction();
        Criteria criteria = session.createCriteria(Coursedetails.class)
                .add(Restrictions.eq("coursename", courseName));
        courselist = (List<Coursedetails>) criteria.list();
        tx.commit();

但我注意到服务器几乎没有警告,可能是对失败的预测。

 Warning: Could not register destruction callback [org.springframework.beans.factory.support.DisposableBeanAdapter@140f0e8] for attribute 'bean' because FacesRequestAttributes does not support such callbacks`
 Warning: Could not register destruction callback [org.springframework.beans.factory.support.DisposableBeanAdapter@13f8471] for attribute 'courseDetailsBean' because FacesRequestAttributes does not support such callbacks
 Warning: Could not register destruction callback [org.springframework.beans.factory.support.DisposableBeanAdapter@ce983a] for attribute 'bean' because FacesRequestAttributes does not support such callbacks
 Warning: Could not register destruction callback [org.springframework.beans.factory.support.DisposableBeanAdapter@16bafa6] for attribute 'courseDetailsBean' because FacesRequestAttributes does not support such callbacks

检查您的spring bean配置文件,是否通过评估id是否正确将BeanDao和CourseDetailsDao声明为bean。 您已用于获取对象引用。

CourseDetailsDAO helper = (CourseDetailsDAO) apc.getBean("courseDetailsDao");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM