2012-12-19 2 views
0

내 JSF 데이터 테이블에 대한 지연로드를 구현하려고하는데 내 응용 프로그램이 JSF2.0을 사용하고 있습니다. 봄 3 및 최대 절전 모드는 4최대 절전 모드를 사용하여 데이터 테이블의 행 수를 Lazyloading

나는 내가

@Entity 
@Table(name = "V_REQUESTS") 
@NamedQueries({ 
    @NamedQuery(name = "Request.count", query = "SELECT COUNT(r) FROM <viewname> r") 
}) 
public class Request { 

문제 내가 직면하고 Entity 클래스에

@Named("reqMB") 
@Scope("request") 
public class RequestManagedBean implements Serializable { 

// other code .....  
lazyModel.setRowCount(getRequestService().getRequestCount()); 
.... 
return lazyModel; 

@Override 
public int getRequestCount() {   
    Query query = entityManager.createNamedQuery("Request.count"); 
    return ((Long) query.getSingleResult()).intValue(); 
} 

및 ManagedBean은에서 DAO에서 다음 한 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 

이 문제를 어떻게 해결할 수 있습니까?

다른 점은 다음을 사용하는 대신 lazyloading에 대한 행 개수를 가져 오는 다른 방법이 있습니까?

@NamedQueries({ 
    @NamedQuery(name = "Request.count", query = "SELECT COUNT(r) 
    FROM vw_request r")}) 

감사

+0

SELECT COUNT (r) FROM r; 은보기의 실제 이름을 어떻게 든 숨기려고하기 때문에 자리 표시 자입니까? 아니면 당신이 해고하는 질문입니다. – Gimby

+0

@Gimby 그 자리 표시 자일뿐입니다. 실제 이름은'vw_request'입니다. – user75ponic

답변

0

내가 문제를 해결하기 위해 관리했다, 내가 만든 실수 대신 클래스 이름의 나는 실제 뷰 이름을 사용했다, 그래서 나는

@NamedQuery(name = "Request.count", query = "SELECT COUNT(r) FROM Request r"). 

내 다른 의심의 여지로 변경 rowcount를 얻기 위해 위 코드를 사용하지 않고 다음과 같이 DAO를 수정했습니다. Entity 클래스에 @NamedQuery가 필요하지 않습니다.

int count = ((Long)sessionFactory.getCurrentSession().createQuery("select count(*) 
from Request").uniqueResult()).intValue(); 
관련 문제