I have an entity defined as below. Mine is a spring data jpa application.
I am using spring boot version 1.5.4.RELEASE
When I invoke service from controller with createDttm
cretDttm=2019-06-11T11:08:03.520808
it's being saved/updated as 2019-06-11 11:08:03.520000. It's discarding last 3 digits of the local date time. Any pointers to fix the same.
@Setter
@Getter
@NoArgsConstructor
@Entity
@ToString
@Table(name = "FOO")
public class Foo {
@Id
@GeneratedValue
@Column(name = "USER_ID")
private BigInteger userId;
@Column(name = "USER_NAME")
private String userName;
@Column(name = "CRET_DTTM", updatable = false)
private LocalDateTime cretDttm;
}
@SpringBootApplication
@EntityScan(basePackageClasses = {Application.class, Jsr310JpaConverters.class})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
UPDATE : The default Jsr310JpaConverters.class doesn't have converter to support java.sql.Timestamp. I created custom converter as mentioned in https://thoughts-on-java.org/persist-localdate-localdatetime-jpa/#highlighter_743982. Annotated the same as mentioned here JPA Cannot Deserialize Java 8 LocalDateTime. It's working now. Thank you.