1

我正在设置 Play!2 具有现有数据库的应用程序。实体已移植到新应用程序。运行应用程序时,我得到一个PersistenceException,因为 ebean 生成的 sql 使用 undercase_notation 而不是 CamelCase,因为它在我之前的应用程序中使用。所以我的restfulIdentifier属性变成了restful_identifier_id 而不是restfulIdentifier_id

我已阅读http://www.avaje.org/ebean/getstarted_props.html上的文档,但找不到设置。

堆:

PersistenceException: Query threw SQLException:Unknown column 't0.restful_identifier_id'
in 'field list' Bind values:[200926947] Query was: select t0.id c0, t0.name c1, t0.state c2,
t0.restful_identifier_id c3 from company t0 where t0.id = ?
4

2 回答 2

1

您将不得不修改实体的元数据以告诉 JPA 您的列现在具有不同的名称。您正在使用注释或 XML 文件。但是,您需要编译源代码(或至少增强它)才能完成它。

于 2012-10-02T09:16:42.080 回答
0

这是一个非常古老的问题,但 Ebean 有 2 个命名约定实现——UnderscoreNamingConvention 和 MatchingNamingConvention ... 而 MatchingNamingConvention 将提供您所追求的骆驼大小写约定。

所以再一次,答案是做

  MatchingNamingConvention namingConvention = new MatchingNamingConvention();

  ServerConfig serverConfig = ...
  serverConfig.setNamingConvention(namingConvention);
于 2016-01-05T19:59:33.370 回答