I\'m developing a Spring Data JPA application, and I\'ve created an AttributeConverter
class in order to save an ArrayList
of objects as JSON in a
With JPA 2.2, Spring 5.1( SPR-16305) and Hibernate 5.3.0 (HHH-12135) you no longer need to use the mutable static property hack and can use dependency injection just like you would on a regular spring managed bean (note that annotations are no longer necessary):
public class MyAttributeConverter implements AttributeConverter {
private final MySpringBean bean;
public MyAttributeConverter(MySpringBean bean) {
this.bean = bean;
}
public Y convertToDatabaseColumn(X attribute) {
...
}
public X convertToEntityAttribute(Y dbData) {
...
}
}