hibernate schema validation failure for LocalDate - found date, but expecting timestamp

Viewed 2435

I had recently tried my application to deploy from JBoss EAP 7.0 to 7.2.4 and since then I am facing this issue with schema validation for fields with LocalDate mapped to the columns of date types.
The exact failure message is:

{"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"project-name.ear#MyPersistenceUnit\"" => "javax.persistence.PersistenceException: [PersistenceUnit: MyPersistenceUnit] Unable to build Hibernate SessionFactory
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: MyPersistenceUnit] Unable to build Hibernate SessionFactory
    Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [someDate] in table [SOME_TABLE]; found [date (Types#DATE)], but expecting [timestamp (Types#TIMESTAMP)]"}}

The snippet from schema:

create table SOME_TABLE(
  -- primiary key and other columns
  someDate date
);

The field in the entity:

@Convert(converter = LocalDateConverter.class)
private LocalDate someDate;

The converter

import java.sql.Date;
import java.time.LocalDate;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

@Converter(autoApply = true)
public class LocalDateConverter
    implements
    AttributeConverter<LocalDate, Date> {

    @Override
    public Date convertToDatabaseColumn(LocalDate attribute) {
        return attribute == null ? null : Date.valueOf(attribute);
    }

    @Override
    public LocalDate convertToEntityAttribute(Date dbData) {
        return dbData == null ? null : dbData.toLocalDate();
    }
}

I found that adding a @Column(columnDefinition = "date") as suggested here solves the issue but my question is:

  1. Do I necessarily need to force to add the columnDefinition in such cases?
  2. The application works well in JBoss 7.0. How can I know what changes introduced in JBoss 7.2.4 which break my application?
  3. Any other recommendation to solve this issue.

This issue is with H2 while connecting with Oracle there is no such issue.

1 Answers
Related