eclipse / jnosql

Eclipse JNoSQL is a framework which has the goal to help Java developers to create Jakarta EE applications with NoSQL.
Other
231 stars 72 forks source link

Improve constructor Builder to convert types #304

Closed otaviojava closed 1 year ago

otaviojava commented 1 year ago

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.