我正在尝试为我的 JSF 数据表实现延迟加载,我的应用程序正在使用 JSF2.0。春季 3 和休眠 4。
我在 DAO 中有以下内容
@Override
public int getRequestCount() {
Query query = entityManager.createNamedQuery("Request.count");
return ((Long) query.getSingleResult()).intValue();
}
在 ManagedBean 我有
@Named("reqMB")
@Scope("request")
public class RequestManagedBean implements Serializable {
// other code .....
lazyModel.setRowCount(getRequestService().getRequestCount());
....
return lazyModel;
在实体类
@Entity
@Table(name = "V_REQUESTS")
@NamedQueries({
@NamedQuery(name = "Request.count", query = "SELECT COUNT(r) FROM <viewname> r")
})
public class Request {
我面临的问题是,当我尝试将应用程序部署到 weblogic 10.3.6 时,出现以下异常。
Error creating bean with name 'requestDAOImpl': Injection of
autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire field: private org.hibernate.SessionFactory
net.test.request.dao.RequestDAOImpl.sessionFactory; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'SessionFactory' defined in ServletContext resource
[/WEB-INF/applicationContext.xml]: Invocation of init method failed;
nested exception is org.hibernate.HibernateException:
Errors in named queries: Request.count
我该如何解决这个问题?
另一点不是使用以下内容,还有其他方法可以获取延迟加载的行数吗?
@NamedQueries({
@NamedQuery(name = "Request.count", query = "SELECT COUNT(r)
FROM vw_request r")})
谢谢