-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
As-Is
@Converter가 적용된 BooleanToIntegerConverter.java 를 추가한 뒤, Converter를 엔티티에 직접 명시하는 방식을 사용하고 있습니다.
@Column(name = "is_sent")
@Convert(converter = BooleanToIntegerConverter.class)
private Boolean isSent = false;Discussion
Oracle DB에서 Boolean 타입이 지원되지 않아서 모든 Boolean 타입 엔티티에 Converter를 사용해야 합니다. 따라서 추후에 Boolean 타입의 엔티티를 몇 개 추가하든 모두 Converter를 명시해야 한다는 단점이 존재합니다. 이를 보완하기 위해 autoApply 옵션을 사용하려고 했으나, 둘 다 장단점이 존재하여 논의해보려고 합니다.
autoApply 옵션에 대한 설명
@Converter(autoApply = true)를 추가해 Converter클래스를 만들게 되면, JPA에서 자동으로 모든 Boolean 타입의 엔티티에 Converter를 적용시켜줍니다.
pros : autoApply를 사용하면 모든 Boolean 엔티티에 자동으로 적용되어, 각 엔티티별로 명시해 줄 필요가 없습니다. 또한, Boolean 엔티티들은 DB에서 전혀 사용이 안되기 때문에, 무조건 Converter를 거쳐야 합니다. 따라서, autoApply를 사용하는 것이 합리적일 수 있습니다.
cons : autoApply를 사용하면 Boolean 엔티티를 작성하면서 해당 엔티티가 어느 Converter에 영향을 받는지 직접적으로 보이지 않습니다. 따라서, 개발을 함에 있어 추후에 혼선이 있을 수 있습니다.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels