This issue can't be edited

Because it belongs to an archived project. Jira admins can restore projects from the archive.

MySQL dialect uses DATETIME for timestamp should be TIMESTAMP

Description

In the hbm.xml, the <timestamp> element generates a SQL
column of type DATETIME.
See MySQLDialect:30 register( Types.TIMESTAMP, "DATETIME" );
MySQL supports a "timestamp" data type, which can be given a value
"null" on insert and will automatically be set to the insert time.

Environment

None

Activity

Show:

Martin KlinkeSeptember 22, 2005 at 1:21 PM

I have a problem with automatic versioning. I'm using Hibernate 3.0.5 and MySQL 4.1.11.
I have tested concurrent updates to ensure the function of optimistic locking.

To enable locking, I have added a timestamp attribute to my hbm.xml as follows:
<timestamp name="lastChanged" column="LAST_CHANGED" />

The problem is now the mapping of timestamp to the MySQL data type DATETIME, which only stores the time with a precision for seconds.
This means that no locking can be performed if concurrent updates occur during the same second (i.e. during the time before the current
time value would change the DATETIME column in the DB.

Since there is the data type TIMESTAMP in MySQL, I don't understand why the hibernate timestamp is not mapped to that data type.

Could anyone please help me out on this?

GavinGAugust 18, 2003 at 10:59 PM

DATETIME is correct.

Rejected

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

GavinG
Martin Klinke
Robert Blumen

Components

Affects versions

Priority

Created August 16, 2003 at 2:57 AM
Updated September 22, 2005 at 1:21 PM
Resolved August 18, 2003 at 10:59 PM