Support for java.time, Optional, and Collections
masterFluentJdbc provides built-in support for several types:
- java.time: Supports
LocalDate,Instant, etc. - java.util.Optional: Automatically handles nullability.
- Collections: Supports passing a
SetorListto a named parameter forINclauses (e.g.,WHERE ID IN (:ids)).
// java.time
query.update("UPDATE CUSTOMER SET DEADLINE = ?")
.params(LocalDate.of(2015, Month.MARCH, 5))
.run();
// Optional
Optional<LocalData> deadline = ...;
query.update("UPDATE CUSTOMER SET DEADLINE = ?")
.params(deadline)
.run();
// Collections (with named parameters)
Set<Long> ids = ...;
query.select("SELECT * FROM CUSTOMER WHERE ID IN (:ids)")
.namedParam("ids", ids)
.listResult(customerMapper);