목차

ValueGenerator

Example

@Column(name = "created_by")
@GeneratorType(
    type = LoggedUserGenerator.class,
    when = GenerationTime.INSERT
)
private String createdBy;
---
// 생성기
// Hibernate session 으로 생성가능
public class LoggedUserGenerator
        implements ValueGenerator<String> {
    @Override
    public String generateValue(
            Session session, Object owner) {
        return LoggedUser.get();
    }
}

참조