我是Play的新手,在部署时遇到问题 在prod模式下应用。 我在内存中使用db开始.... 播放版本为1.2.4 我用实体制作了一个简单的应用程序
@Entity
public class TestModel extends Model {
public String name;
}
和conf as
application.mode=prod
db=mem
%test.application.mode=prod
%test.db.url=jdbc:h2:mem:play;MODE=MYSQL;LOCK_MODE=0
%test.jpa.ddl=create
%test.mail.smtp=mock
控制器中的仅用于测试我正在做的是
public static void listBars() {
TestModel bar = new TestModel();
bar.name = "a new bar";
bar.save();
TestModel bar2 = new TestModel();
bar2.name = "a new bar2";
bar2.save();
renderJSON(TestModel.findAll());
}
真的很感激,如果我能得到一些帮助..代码正在开发模式..
异常跟踪是
va:116)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.prepare(I
entityGenerator.java:90)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(Abstr
ctReturningDelegate.java:54)
... 24 more
9:57:31,396 WARN ~ SQL Error: 42102, SQLState: 42S02
9:57:31,397 ERROR ~ Table "TESTMODEL" not found; SQL statement:
nsert into TestModel (id, name) values (null, ?) [42102-149]
9:57:31,404 ERROR ~
69772kodd
nternal Server Error (500) for request POST /bars.json
xecution exception (In /app/controllers/Application.java around line 30)
ersistenceException occured : org.hibernate.exception.SQLGrammarException: coul
not insert: [models.TestModel]
lay.exceptions.JavaExecutionException: org.hibernate.exception.SQLGrammarExcept
on: could not insert: [models.TestModel]
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:231)
at Invocation.HTTP Request(Play!)
aused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGr
mmarException: could not insert: [models.TestModel]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityMan
gerImpl.java:1214)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityMan
gerImpl.java:1147)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityMan
答案 0 :(得分:1)
你需要使用这样的东西来自动生成你的表:
jpa.ddl =创建
每次生产时都不要重新生成表格,以防止丢失数据。
查看此页面:http://www.playframework.org/documentation/1.2.4/production 部分:禁用JPA自动架构更新