I have an Entity
CustomEntity with a data member updateDate of type OffsetDateTime
.
I have defined a Repository
for this Entity
which has a simple method to retrieve list of records matching updateDate as
List<CustomEntity> findByUpdateDate(OffsetDateTime updateDate);
Now, when this method is called from Controller/Service bean, I can see no matching record is retrieved; however, when I execute the generated SQL in the DB, I can see matching rows available.
I can retrieve the records based on other data members of the entity; its just an issue with OffsetDateTime
and LocalDateTime
I got to understand that java.time
package support was not in JPA 2.1; however I am using JPA 2.3.1. Do I need to use Converter
s (as suggested for JPA 2.1?
Any help is much appreciable.
EDIT :- Below is the code for Entity
@Entity
@Table(name = "SAMPLE_TABLE")
public class CustomEntity {
@Id
@GeneratedValue
private Long id;
@Column
private OffsetDateTime updateDate;
//Getters & Setters
}
I am using Microsoft SQL Server and the generated SQL
query (hibernate generated) looks something like below
select sample0_.id as id1_10, sample0_.updateDate as update2_10 from sample_table sample0_ where sample0_.updateDate=?
binding parameter [1] as [TIMESTAMP] - [2021-07-27T17:22:34.597Z]