我刚刚开始使用Spring和Hibernate进行冒险,我遇到了以下错误(我找不到解决方法如何克服它)
SEVERE:servlet [Faces Servlet]的Servlet.service()与上下文有关 path [/ JavaTest_hib2]抛出异常[Property [listWig20Opening] 在[com.sun.proxy。$ Proxy27]类型中找不到根本原因 javax.el.PropertyNotFoundException:Property [listWig20Opening] not 在[com.sun.proxy。$ Proxy27]
类型上找到
这在打开xhtml时会导致错误:
<p:dataTable var="wig20o" value="#{wig20Service.listWig20Opening()}"
style="width:200px;">
<p:column headerText="opening">
${wig20o}
</p:column>
Wig20Service实施:
@Service
@ManagedBean(name = "wig20ServiceImpl")
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
public class Wig20ServiceImpl implements Wig20Service {
@ManagedProperty("#{wig20}")
private Wig20DAOImpl wig20DAOImpl;
public Wig20DAOImpl getWig20DAOImpl() {
return wig20DAOImpl;
}
public void setWig20DAO(Wig20DAOImpl wig20DAO) {
wig20DAOImpl = wig20DAO;
}
@Override
@Transactional
public List<Wig20> listWig20() {
return this.wig20DAOImpl.listWig20();
}
@Override
@Transactional
public List<Double> listWig20Opening() {
return this.wig20DAOImpl.listWig20Opening();
}
}
和Wig20DAO实施:
@Repository
@ManagedBean(name = "wig20Impl")
public class Wig20DAOImpl implements Wig20DAO{
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sf) {
this.sessionFactory = sf;
}
@SuppressWarnings("unchecked")
public List<Wig20> listWig20() {
Session session = sessionFactory.getCurrentSession();
session.beginTransaction();
List<Wig20> wig20List = session.createQuery("from Wig20").list();
return wig20List;
}
@SuppressWarnings("unchecked")
public List<Double> listWig20Opening() {
Session session = sessionFactory.getCurrentSession();
session.beginTransaction();
Query query = session.createSQLQuery("CALL GetWig20Opening()");
List<Double> wig20ListOpening = null;
wig20ListOpening.addAll(query.list());
return wig20ListOpening;
}
}
PS。我知道此代码中可能存在其他错误,但是现在我想摆脱代理错误。
PPS。我发现提示添加CGLIB和@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS),但不幸的是它不起作用。
非常感谢你的帮助