This question already has an answer here:
I want to set some entity rules for JPA entity mapping. Very simple example would be if have an entity
@Entity
@Table(name = "my_table")
public class {
@Id
private Integer id;
private boolean flagged;
....
}
my flagged value is String in db marked as Yes/null/No. I want my flagged value to be set as true if value null/yes. false otherwise. Is there any way to define this custom rule on bean mapping for JPA entities. This is a simple example, would need to use this for complex rules as well. Appreciate your help.
Thanks
You could write your own converter. Use the code below as a start point and adapt to your use case
}
And the converter as:
Hibernate
Java