hibernate - 분할 된 postgresql을 가진 최대 절전 모드 인서삽입 배치
insert database-partitioning (4)
hibernate.jdbc.factory_class 속성을 설정하여 커스텀 Batcher를 사용해 볼 수도있다. 최대 절전 모드로 일괄 작업의 업데이트 횟수를 확인하지 않으면 문제를 해결할 수 있습니다. 사용자 정의 Batcher를 클래스 BatchingBatcher로 확장 한 다음 doExecuteBatch (...) 메소드를 다음과 같이 재정 의하여 구현할 수 있습니다.
@Override
protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException {
if ( batchSize == 0 ) {
log.debug( "no batched statements to execute" );
}
else {
if ( log.isDebugEnabled() ) {
log.debug( "Executing batch size: " + batchSize );
}
try {
// checkRowCounts( ps.executeBatch(), ps );
ps.executeBatch();
}
catch (RuntimeException re) {
log.error( "Exception executing batch: ", re );
throw re;
}
finally {
batchSize = 0;
}
}
}
새 메서드는 준비된 문을 실행 한 결과를 확인하지 않습니다. 이 변경 작업은 예상치 못한 방식으로 최대 절전 모드에 영향을 미칠 수 있습니다 (또는 아닐 수도 있음).
거기에 파티션 된 postgresql 테이블에 최대 절전 모드를 통해 배치 삽입에 대한 해결책은 무엇입니까? 현재 나는 이런 오류가 발생했습니다 ...
ERROR org.hibernate.jdbc.AbstractBatcher - Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)....
나는이 링크 http://lists.jboss.org/pipermail/hibernate-dev/2007-October/002771.html 을 발견했다. 그러나 나는 웹상의 어디에서나 찾을 수 없다.이 문제는 해결 되었는가, 아니면 어떻게 돌아갈 수 있는가?
thnx! 그것은 트릭을 BatcherFactory
지금까지는 아무런 문제도 발생하지 않았다.) .... 한가지 ... 너는 ... BatcherFactory
클래스를 구현하고 int에 persistence.xml
파일을 넣어야했다.
property name="hibernate.jdbc.factory_class" value="path.to.my.batcher.factory.implementation"
그 공장에서 위의 코드로 내 배터 구현을 호출했습니다.
ps 동면 코어 3.2.6 GA
다시 한번 감사합니다
이들은 파티션 된 테이블이나 @SQLInsert 주석에서 두 개의 트리거를 사용한다고 말합니다. http://www.redhat.com/f/pdf/jbw/jmlodgenski_940_scaling_hibernate.pdf 21-26 페이지 (문자열을 지정하는 @SQLInsert에 대한 언급이 있습니다. 방법).
다음은 마스터에서 추가 행을 삭제하는 after 트리거가있는 예입니다. https://gist.github.com/copiousfreetime/59067
하이버 네이트를 통해 문서를 삽입하는 동안 같은 문제가 발생했습니다. 많은 수의 검색 후에 업데이트 된 행이 반환되어야하므로 null 대신 null을 트리거 프로 시저에서 새 것으로 변경해야합니다. 그러면 아래와 같이 문제가 해결됩니다.
새로운 돌아 가기