Hey,
I keep running into a problem which i just can't figure out how to get around.
I've got an entity Track:
Code:
<?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.Track" table="track">
<id column="id" length="36" name="id" type="java.lang.String">
<generator class="com.tracker.robot.db.generator.CustomUUIDGenerator"/>
</id>
<version column="updated" name="updated" type="java.util.Calendar" unsaved-value="null" generated="always" />
[....]
</hibernate-mapping>
I try to do an versioned update of this entity using HQL:
Code:
Query q = currentSession.createQuery("update Track t set t.flag = :flag where t.id = :id");
This works most of the time. However, the query is "converted" to SQL using [...] set t.flag = [value], t.updated=updated+1. Now, this is the root of the issue. Somehow, MySQL throws an exception here whenever the 'updated' field ends with 59 (the 59th second of a minute). The next second would be 0 in the subsequent minute. However, MySQL doesn't handle this and throws an exception.
Does anyone have any ideas about how i can solve this? Do i need to modify the MySQL dialect and have it to use for instance NOW() instead of just adding one to the existing update value.
All help would be highly appreciated!