"Unsuccessful: create table"エラーの解決

PlayFrameworkを用いて開発していたところ,db=mem環境では動いていたのに,MySQLに移行したところ,動かなくなってしまった.

調べてみると,Entityクラスを元にMySQLのテーブル自動生成時にエラーがでており,一部のテーブルが生成されていなかった.

元となったEntityクラス

package models;

import javax.persistence.Entity;
import javax.persistence.Lob;
import play.db.jpa.Model;

/**
 * @author Syo.Takasaki
 */
@Entity
public class TestCondition extends Model {
    
    @Lob
    public String condition;
    
    public Integer priority;
    
    @Lob
    public String comment;
}

出力されたエラー

20:44:43,596 ERROR ~ Unsuccessful: create table TestCondition (id bigint not null auto_increment, comment longtext, condition longtext, priority integer, primary key (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8
20:44:43,597 ERROR ~ You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition longtext, priority integer, primary key (id)) ENGINE=InnoDB DEFAULT CH' at line 1

なお,MySQLのバージョンは5.1である.
出力されたcreate tableを直接叩いてみたが,同様のエラー.

解決(というか原因)

もしかして予約語使っていないか? と気づき,MySQLの仕様を調べ……る前にカラム名を変えてみた.
結果,conditionを使わなければ見事(?)にテーブルが生成された.

結論:conditionは使ってはダメです.

http://dev.mysql.com/doc/refman/5.1/ja/reserved-words.html予約語一覧にもしっかり書いてありました.