2013-04-06 62 views
2

在兩個模型(本例中爲User和Article模型[1])上添加@ManyToMany連接表後,Play會正確檢測這些更改並相應地修改1.sql [2]文件:Play 2.1框架未檢測到進化變化

[1] 
+ @ManyToMany 
+ public List<User> authors; 

+ @ManyToMany(mappedBy="authors") 
+ public List<Article> authoredArticles; 

[2] 
+ create table articles_users (
+  articles_id     bigint not null, 
+  users_id      bigint not null, 
+  constraint pk_articles_users primary key (articles_id, users_id) 
+ ); 

+ alter table articles_users add constraint fk_articles_users_articles_01 foreign key (articles_id) references articles (id); 
+ alter table articles_users add constraint fk_articles_users_users_02 foreign key (users_id) references users (id); 

# --- !Downs 

+ drop table if exists articles_users cascade; 

但是打開使用這種關係頁面時,將顯示演變需要申請,而不是呈現以下錯誤無消息:

PersistenceException: Query threw SQLException:ERROR: relation "articles_users" does not exist 

爲什麼玩不檢測,它已經做了修改需要應用的數據庫模式?

+0

在生產或開發環境中,您有這個問題嗎? – MaFo 2013-04-07 13:15:50

+0

開發,該應用程序目前尚未投入生產。 – HaaR 2013-04-07 14:57:46

回答

2

檢查play_evolutions表,如果已經有id爲1的行,則必須將sql文件重命名爲2.sql或手動刪除表。

+0

是的,你是對的。這個對我有用。 – BalaB 2015-04-03 18:14:02