I have a JPA entity where there is an updatedTime of type LocalDateTime column. I want to save it automatically through JPA with current time stamp , without setting any value in the entity object while saving. I looked at examples using Temporal annotations and also using column definition, but the second one saves it with null while the first one says this is allowed on type Date only. Can some please help me here? Note that I don't want to use triggers.
References: Setting a JPA timestamp column to be generated by the database?
http://www.java2s.com/Tutorials/Java/JPA/0160__JPA_Date_Column_Definition.htm
I have tried using using attribute converter as well, still the column is null. This is how the column is defined:
It doesn't work with the attribute converter either. This is how I have defined the column in entity: @Column(name="UPDATED_AT" , nullable=false,updatable=false, insertable=false, columnDefinition="TIMESTAMP DEFAULT CURRENT_TIME"
private LocalDateTime updatedTs;