4
我正在使用H2數據庫來測試我的Grails應用程序。我有一些簡單的域類,如:表創建失敗
package mypackage
class UserSession {
User user
String sessionTokenHash
// last seen info
String lastSeenIP
Date lastSeenTime
String lastSeenUserAgent
String lastSeenURL
}
但是,該表似乎無法正確創建。
hbm2ddl.SchemaExport Unsuccessful: create table user_session (id bigint not null auto_increment, version bigint not null, last_seenip varchar(255) not null, last_seen_time datetime not null, last_seenurl varchar(255) not null, last_seen_user_agent varchar(255) not null, session_token_hash varchar(255) not null, user_id bigint not null, primary key (id)) ENGINE=InnoDB hbm2ddl.SchemaExport Syntax error in SQL statement "CREATE TABLE USER_SESSION (ID BIGINT NOT NULL AUTO_INCREMENT, VERSION BIGINT NOT NULL, LAST_SEENIP VARCHAR(255) NOT NULL, LAST_SEEN_TIME DATETIME NOT NULL, LAST_SEENURL VARCHAR(255) NOT NULL, LAST_SEEN_USER_AGENT VARCHAR(255) NOT NULL, SESSION_TOKEN_HASH VARCHAR(255) NOT NULL, USER_ID BIGINT NOT NULL, PRIMARY KEY (ID)) ENGINE=[*]INNODB "; expected "identifier"; SQL statement: create table user_session (id bigint not null auto_increment, version bigint not null, last_seenip varchar(255) not null, last_seen_time datetime not null, last_seenurl varchar(255) not null, last_seen_user_agent varchar(255) not null, session_token_hash varchar(255) not null, user_id bigint not null, primary key (id)) ENGINE=InnoDB [42001-147]
它被設置爲使用create-drop
模式下的臨時內存H2數據庫。
不知道這是否是問題,但我試圖遠離「我的域名中的」用戶「和」會話「這樣的」常用「單詞,因爲它們可能具有某種受保護的grails行爲,甚至可能有一些保留用途在H2中。 – Mikey 2012-04-17 16:50:44