We're updating the issue view to help you get more done. 

Unnecessary ALTER TABLE statements on TIMESTAMP fields in MySQL

Description

All my ActiveObjects entities have the fields "created_at" and "updated_at" for storing the creation date and the last updated date. In MySQL ActiveObjects defines those fields as TIMESTAMP fields, the first field has set "DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" and the second "DEFAULT '0000-00-00 00:00:00'", even i didn't declare any default values in the entity class (this is a feature of MySQL...). Now i see all those ALTER TABLE statements in the log on every request:

2011-06-27 09:43:20,317 DEBUG [http-8080-3] [net.java.ao.sql] onSql ALTER TABLE AO_7BE59C_XXX_ENTITY CHANGE COLUMN UPDATED_AT UPDATED_AT TIMESTAMP
2011-06-27 09:43:20,943 DEBUG [http-8080-3] [net.java.ao.sql] onSql ALTER TABLE AO_7BE59C_XXX_ENTITY CHANGE COLUMN CREATED_AT CREATED_AT TIMESTAMP
...

It seems like ActiveObjects is thinking that something has changed and tries to migrate the tables. When i set @Default("CURRENT_TIMESTAMP") on "created_at" the ALTER TABLE statement disappears. Sadly, you can not define "ON UPDATE CURRENT_TIMESTAMP" on multiple columns in the same table. Are you able to reproduce this behaviour?

It also looks like somebody already had this problem before: http://java.net/jira/browse/ACTIVEOBJECTS-35

Environment

  • Confluence 3.4.1

  • mysql-5.5.8-osx10.6-x86_64

  • mysql-connector-java-5.1.11

Testing Notes

None

Status

Assignee

Samuel Le Berrigaud

Reporter

RemoS

Labels

None

Add-on Type

None

Team

None

CC

None

Risk factor

None

QA Kickoff Status

None

QA Demo Status

None

Components

Fix versions

Affects versions

ao-plugin 0.14.1

Priority

Major