Improve constructor Builder to convert types
otaviojava opened this issue · comments
Otávio Santana commented
Currently, on the constructor process, there is no convert process.
So, data from the database must be precisely the one from the constructor parameter.
Given an entity:
@Entity
public record Book(@Id String id, @Column("name") String name,
@Column("author") String author,
@Column("year") Year year) {
}
When we execute a retrieve:
Template template = container.select(Template.class).get();
Book book = new Book(id, "cool", "Otavio", Year.now());
template.insert(book);
Optional<Book> optional = template.find(Book.class, id);
It will return an exception because the field Year
is converted to String.
So the class ParameterConverter
needs to be smater and converts it before adding on the parameter.