Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-23193

[GSS](7.4.z) HV-1878 - Hibernate validator: UnsupportedOperationException at java.sql.Date.toInstant(Date.java:316)

XMLWordPrintable

      Customer is migrating from EAP 7.1 to EAP 7.4 and they hit an issue regarding conversion of java.sql.Date to TemporalType.DATE.
      They have a column

      @Column(nullable = false)
          @NotNull
          @Past
          @Temporal(TemporalType.DATE)
          public Date getDob() {
      	return dob;
          }
      

      This results in

      Caused by: java.lang.UnsupportedOperationException
      	at java.sql/java.sql.Date.toInstant(Date.java:316)
      	at org.hibernate.validator@6.0.22.Final-redhat-00002//org.hibernate.validator.internal.constraintvalidators.bv.time.past.PastValidatorForDate.getInstant(PastValidatorForDate.java:23)
      	at org.hibernate.validator@6.0.22.Final-redhat-00002//org.hibernate.validator.internal.constraintvalidators.bv.time.past.PastValidatorForDate.getInstant(PastValidatorForDate.java:19)
      	at org.hibernate.validator@6.0.22.Final-redhat-00002//org.hibernate.validator.internal.constraintvalidators.bv.time.AbstractInstantBasedTimeValidator.isValid(AbstractInstantBasedTimeValidator.java:55)
      	at org.hibernate.validator@6.0.22.Final-redhat-00002//org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateSingleConstraint(ConstraintTree.java:171)
      

      exception if they try to do merge. (I've attached their test case). I modified their test case and change table definition from DATE to TIMESTAMP the the column definition to @Temporal(TemporalType.TIMESTAMP) and that seem to fixed the issue. But customer says this is unacceptable to them. They claim that it used to work in EAP 7.1.
      I have reproduced the issue in EAP 7.4.2 but reading the java.sql.DATE I'm surprised that it ever worked since the docs imply that java.sql.DATE works that way. Am I missing something? Is there a work around it?

              thofman Tomas Hofman
              thofman Tomas Hofman
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: