Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- Apache Lucene
- asp.net
- 웹 서비스
- javascript
- 웹뷰
- Android
- 컬럼명
- 안드로이드
- SpringSource Tool Suite
- MANTIS
- 자바
- MS-SQL
- 이클립스
- TextBox
- C#
- decompiler
- Maven
- WebView
- varags
- MSsql
- Web Service
- Redirect
- Eclipse
- jsp
- Bootstrap
- STS
- 자바스크립트
- Java
- scrollView
- html
Archives
- Today
- Total
bboks.net™
Hibernate Criteria 재사용 본문
Hibernate를 사용하다보면 Criteria를 재사용할 상황이 가끔 생긴다.
예를 들면 Paging과 같은
nHibernate에는 CriteriaTransformer(?)에서 지원을 하는 것 같은데 hibernate에서는 없는 것 같음
이를 우회하는 방법은 criteria의 projection을 초기화하고 다시 세팅하는 방법이 있다.
ProjectionList projectionList = Projections.projectionList(); //전체 개수를 가져옴 int totalCount = Integer.parseInt(criteria.setProjection(Projections.rowCount()).list().get(0).toString()); //criteria 재사용을 위해 projection를 초기화하고 다시 설정 criteria.setProjection(null); criteria.setProjection(projectionList);