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

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


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37099#action_37099 ] 

Ian Haken commented on HHH-5219:
--------------------------------

I looked through the bugs for 3.5.x and didn't see anything describing the same problem; you might be thinking of HHH-4920, which sounds similar but I think describes a separate issue.

> 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