[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5219) DATETIME column incorrectly validates against DATE column

Ian Haken (JIRA) noreply at atlassian.com
Wed May 12 13:29:24 EDT 2010


DATETIME column incorrectly validates against DATE column
---------------------------------------------------------

                 Key: HHH-5219
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5219
             Project: Hibernate Core
          Issue Type: Bug
    Affects Versions: 3.5.1
            Reporter: Ian Haken
         Attachments: validation-fix.patch

org.hibernate.mapping.Table.validateColumns incorrectly validates if the expected SqlType is DATETIME and the actual SqlType is DATE. This can be reproduced as follows:

Create a MySQL table with DATE type for column foo.
Create an Entity with java.util.Date member foo, annotated with @Temporal(TemporalType.TIMESTAMP).
Initiate a Hibernate session with hibernate.hbm2ddl.auto=validate.

An exception should be thrown and is not. Looking at the code in src/main/java/org/hibernate/mapping/Table.java, it is clear why this would occur; the check is:
col.getSqlType( dialect, mapping ).toLowerCase().startsWith( columnInfo.getTypeName().toLowerCase() )

I'm not sure if there was a particular reason for using startsWith rather than equals, but I've changed startsWith to equals in the suggested patch (attached).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list