I want to implement a custom column handler in Hibernate/Spring Boot app. I tries this:
Entity:
@Entity
@Table(name = "single_user")
@Getter
@Setter
public class SingleUser {
@Id
@SequenceGenerator(name = "su_seq", sequenceName = "su_seq", allocationSize = 100)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "su_seq")
@Column(name = "id", nullable = false)
private Long id;
@Convert(converter = ExpiryDateTypeHandler.class)
@Column(name = "expiry_date")
private ExpiryDate expiryDate;
// getter, setter
}
Spring JPA repository:
SingleUserDao entity;
singleUserRepository.create(entity.getId(),
.....,
Optional.ofNullable(entity.getRecipient()).map(CalendarDate::getYear).orElse(0),
I get error:
[ERROR: column "card_expiry_date" is of type date but expression is of type bytea
Hint: You will need to rewrite or cast the expression.
Position: 215] [n/a]; SQL [n/a]] with root cause
org.postgresql.util.PSQLException: ERROR: column "card_expiry_date" is of type date but expression is of type bytea
Hint: You will need to rewrite or cast the expression.
Basic reproducible code: https://github.com/rcbandit111/JdbcTypePoc.git
Do you know how I can implement the column AttributeConverter properly when I insert new line?