Play Framework 2.4 Ebean Id Generation

送分小仙女□ 提交于 2019-12-05 21:13:51

Anyways, I got it to work, if anyone has the same problem the following fixes it:

public class MyServerConfigStartup implements ServerConfigStartup {
@Override
public void onStart(ServerConfig serverConfig) {
    PostgresPlatform postgresPlatform = new PostgresPlatform();
    DbIdentity dbIdentity = postgresPlatform.getDbIdentity();
    dbIdentity.setSupportsGetGeneratedKeys(false);
    dbIdentity.setSupportsSequence(true);
    dbIdentity.setIdType(IdType.GENERATOR);
    serverConfig.setDatabasePlatform(postgresPlatform);
}

}

Expanding Rob's comment into a real answer:

Putting ebean.databasePlatformName=postgres8

in conf/ebean.properties will force the Play 2.3 default of using a PostgreSQL Sequence to generate IDs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!