0

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")})

ありがとう

4

1 に答える 1

0

問題を解決できました。実際のビュー名を使用したクラス名の代わりに間違いを犯したため、に変更しました

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

私のもう1つの疑問は、上記を使用して行数を取得しないことでした.DAOを次のように変更しました。これにより、Entityクラスに@NamedQueryを含める必要がなくなりました。

int count = ((Long)sessionFactory.getCurrentSession().createQuery("select count(*) 
from Request").uniqueResult()).intValue();
于 2012-12-19T12:56:30.320 に答える