I\'ve got a class which contains an atttribute of java.time.LocalDateTime type.
public class MyClass{
// ...
private LocalDateTime fecha;
// ...
}
>
Zombie Thread, but thought I'd throw my solution into the ring.
I had a similar issue, I ended up using a Hibernate @Formula
For example:
class MyClass {
private LocalDateTime fecha;
/* fecha referenced within the annotation should be the column name.
* So, if it's different the Java field name (i.e. fecha_dtm or something),
* make sure to use it.
*/
@Formula("CAST(fecha as DATE)")
private LocalDate fechaDate;
}
Then your repository:
public interface IRepository extends CrudRepository {
deleteByFechaDate(LocalDate fecha); // note it's FechaDate, not Fetcha
}
Try to stick to ANSI SQL compliant functions (CAST
is SQL-92 compliant, so pretty widely accepted) to keep things consistent across database implementations. However, DB specific functions can be used, you'll just lose portability.
Hopefully this helps you!