Commit e58947bf authored by Selvakumar Kamatchinathan's avatar Selvakumar Kamatchinathan
Browse files

changed ZonedDateTime to Timestamp

parent 30593aca
......@@ -25,7 +25,6 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.EnumType;
......@@ -33,7 +32,7 @@ import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.ZonedDateTime;
import java.sql.Timestamp;
@Entity
@EntityListeners({AuditingEntityListener.class, EntityEventListener.class})
......@@ -91,12 +90,10 @@ public class Phenotype implements IdentifiableEntity<String> {
@CreatedDate
@Column(updatable = false)
@Convert(converter = ZonedDateAttributeConverter.class)
private ZonedDateTime createdDate;
private Timestamp createdDate;
@LastModifiedDate
@Convert(converter = ZonedDateAttributeConverter.class)
private ZonedDateTime lastModifiedDate;
private Timestamp lastModifiedDate;
public Phenotype() {
}
......
......@@ -25,7 +25,6 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.EnumType;
......@@ -33,7 +32,7 @@ import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.ZonedDateTime;
import java.sql.Timestamp;
@Entity
@EntityListeners({AuditingEntityListener.class, EntityEventListener.class})
......@@ -98,12 +97,10 @@ public class Property implements IdentifiableEntity<String> {
@CreatedDate
@Column(updatable = false)
@Convert(converter = ZonedDateAttributeConverter.class)
private ZonedDateTime createdDate;
private Timestamp createdDate;
@LastModifiedDate
@Convert(converter = ZonedDateAttributeConverter.class)
private ZonedDateTime lastModifiedDate;
private Timestamp lastModifiedDate;
public Property() {
}
......
/*
*
* Copyright 2019 EMBL - European Bioinformatics Institute
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package uk.ac.ebi.ampt2d.registry.entities;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.sql.Timestamp;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@Converter(autoApply = true)
public class ZonedDateAttributeConverter implements AttributeConverter<ZonedDateTime, Timestamp> {
@Override
public Timestamp convertToDatabaseColumn(ZonedDateTime zonedDateTime) {
return (zonedDateTime == null ? null : Timestamp.valueOf(zonedDateTime.toLocalDateTime()));
}
@Override
public ZonedDateTime convertToEntityAttribute(Timestamp sqlTimestamp) {
return (sqlTimestamp == null ? null : sqlTimestamp.toLocalDateTime().atZone(ZoneId.systemDefault()));
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment