문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 마지막 판 양쪽 다음 판 | ||
java:hibernate:envers [2018/12/11 15:24] kwon37xi |
java:hibernate:envers [2020/04/23 16:37] kwon37xi |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== Hibernate Envers ====== | ====== Hibernate Envers ====== | ||
* [[http:// | * [[http:// | ||
- | * Hibernate audit | + | * Hibernate/JPA Entity의 변경 사항을 추적할 수 있게 별도 테이블에 변경 사항을 자동 저장해준다. |
+ | * [[https:// | ||
+ | |||
+ | ===== REV 를 long 으로 변경해야한다 ===== | ||
+ | * 이력이 쌓일 때 이력의 값을 '' | ||
+ | * 이 경우 약 20억 이상의 이력이 쌓이면 곧바로 오류가 발생하게 된다. | ||
+ | * '' | ||
+ | * '' | ||
+ | <code java> | ||
+ | @Entity | ||
+ | @RevisionEntity | ||
+ | public class CustomRevisionEntity implements Serializable { | ||
+ | @Id | ||
+ | @GeneratedValue | ||
+ | @RevisionNumber | ||
+ | private long rev; | ||
+ | @RevisionTimestamp | ||
+ | private long timestamp; | ||
+ | /* provide getter/ | ||
+ | } | ||
+ | </ | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | ===== Custom @RevisionEntity ===== | ||
+ | * '' | ||
+ | * [[https:// | ||
+ | |||
+ | ===== ToOne 관계의 join column | ||
+ | > If you want to audit a relation, where the target entity is not audited (that is the case for example with dictionary-like entities, which don't change and don't have to be audited), just annotate it with @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED). Then, when reading historic versions of your entity, the relation will always point to the " | ||
+ | |||
+ | * 관계맺은 엔티티 자체는 audit 하지 않고, join column 값의 변화면 검사하고자 한다면 관계 매핑에 '' | ||
===== 참조 ===== | ===== 참조 ===== | ||
+ | * [[https:// | ||
* [[https:// | * [[https:// | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// |