문서의 선택한 두 판 사이의 차이를 보여줍니다.
다음 판 | 이전 판 | ||
java:hibernate:valuegenerator [2021/10/07 21:19] kwon37xi 만듦 |
java:hibernate:valuegenerator [2021/10/07 21:48] (현재) kwon37xi [Example] |
||
---|---|---|---|
줄 2: | 줄 2: | ||
* [[https:// | * [[https:// | ||
+ | |||
+ | ===== Example ===== | ||
+ | <code java> | ||
+ | @Column(name = " | ||
+ | @GeneratorType( | ||
+ | type = LoggedUserGenerator.class, | ||
+ | when = GenerationTime.INSERT | ||
+ | ) | ||
+ | private String createdBy; | ||
+ | --- | ||
+ | // 생성기 | ||
+ | // Hibernate session 으로 생성가능 | ||
+ | public class LoggedUserGenerator | ||
+ | implements ValueGenerator< | ||
+ | @Override | ||
+ | public String generateValue( | ||
+ | Session session, Object owner) { | ||
+ | return LoggedUser.get(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
===== 참조 ===== | ===== 참조 ===== | ||
+ | * [[https:// | ||
+ | ]] | ||
* [[https:// | * [[https:// | ||
- | * | + | * [[https:// |