[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-5449) Versioned HQL update might issue incorrect SQL
Steve Ebersole (JIRA)
noreply at atlassian.com
Fri Aug 13 12:46:41 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Ebersole closed HHH-5449.
-------------------------------
Resolution: Fixed
> Versioned HQL update might issue incorrect SQL
> ----------------------------------------------
>
> Key: HHH-5449
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5449
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.5.4
> Environment: Hibernate 3.5.4 and MySQL.
> Reporter: Stian Brattland
> Assignee: Steve Ebersole
> Priority: Minor
> Fix For: 3.6.0.Beta3, 3.5.5
>
> Time Spent: 19m
> Remaining Estimate: 0h
>
> When executing a versioned HQL update, the version column (java.util.Calendar) is updated using 'updated=updated+1'. Some MySQL versions will throw an exception whenever the incremented value ended with 59. For instance, if the previous version value was '2010-03-12 13:00:59', then MySQL will throw an exception as the incremented value would be '2010-03-12 13:00:60' (see http://dev.mysql.com/doc/refman/5.0/en/time-zone-leap-seconds.html for more on this).
> In this case, Hibernate would throw the exception 'SEVERE: Data truncation: Incorrect datetime value: '20100302130060.000000' for column 'updated' at row 1'.
> I've received feedback on this issue through the Hibernate forum which indicates that this might be a bug (https://forum.hibernate.org/viewtopic.php?f=1&t=1006238)
> ** Entity.hbm.xml **
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping>
> <class name="com.tracker.robot.db.entities.Entity" table="track">
> <id column="id" length="36" name="id" type="java.lang.String" />
> <version column="updated" name="updated" type="java.util.Calendar" unsaved-value="null" />
> <property column="title" length="255" name="title" type="java.lang.String"/>
>
> </class>
> </hibernate-mapping>
> ** Entity.java **
> import java.util.Calendar;
> public class Entity {
> private String id;
> private String title;
> private Calendar updated;
> public Entity() {
> }
> public String getId() {
> return id;
> }
> public void setId(String id) {
> this.id = id;
> }
> public String getTitle() {
> return title;
> }
> public void setTitle(String title) {
> this.title = title;
> }
> public Calendar getUpdated() {
> return updated;
> }
> public void setUpdated(Calendar updated) {
> this.updated = updated;
> }
> }
> ** TestCode **
> currentSession.beginTransaction();
> Query q = currentSession.createQuery("update versioned Entity e set e.title = :title where e.id = :id");
> q.setString("title", "TEST");
> q.setString("id", "000059e4-8b71-41c1-81f2-5cacabba5554");
> q.executeUpdate();
> currentSession.getTransaction().rollback();
--
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