HibernateTemplate 페이지 조회
public class TCompanyDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(TCompanyDAO.class);
//(1)
private static HibernateTemplate hibernateTemplate =new HibernateTemplate (HibernateSessionFactory.getSessionFactory());
//(2)
protected void initDao() {
// do nothing
}
public static List getCompanyListForPage(final int offset, final int lengh) {
log.debug("finding getCompanyListForPage ");
try {
List list = hibernateTemplate.executeFind(new HibernateCallback(){
String queryString = "from TCompany";
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
List list2 = session.createQuery(queryString)
.setFirstResult(offset)
.setMaxResults(lengh)
.list();
return list2;
}});
return list;
} catch (RuntimeException re) {
log.error("find ListForPage failed", re);
throw re;
}
}
}
이상 의 코드 는 프로그램 이 실 행 될 때 제3자 소프트웨어 로 데 이 터 를 삽입 할 때 이 방법 으로 최신 데 이 터 를 얻 을 수 없습니다.
해결 방법 은 다음 과 같다.
나 는 두 곳 의 수정 을 할 것 이다.
위의 빨 간 글 자 를 보 세 요.
(1) //
private static HibernateTemplate hibernateTemplate;
(2) protected void initDao() {
// do nothing
hibernateTemplate=getHibernateTemplate();// HibernateDaoSupport
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Spring에서 DAO가 순환 호출될 때 데이터가 실시간으로 업데이트되지 않는 해결 방법문제를 설명하기 전에 몇 가지 전제 사항을 설명하십시오. Spring의 구성 파일에서 다음과 같은 방식으로 데이터베이스 트랜잭션을 구성했다고 가정하십시오. 현재 UserDao 및 Security Service가 있습...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.