2012-10-02 18 views
1

我正在设置Play! 2应用程序与已有的数据库。这些实体已被移植到新的应用程序。在运行应用程序时,我得到一个PersistenceException因为 由ebean生成的sql使用undercase_notation而不是像我在前面的应用程序 中那样使用CamelCase。所以我的restfulIdentifier财产变成restful_identifier_id 而不是restfulIdentifier_idEbean按预期生成带有undercase_notation而非CamelCase的sql

我已阅读文档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 = ? 

回答

1

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

0

这是一个非常古老的问题,但Ebean有2个命名约定实现 - UnderscoreNamingConvention和MatchingNamingConvention ...以及MatchingNamingConvention将提供您之后的骆驼案例约定。

如此反复,答案是做

MatchingNamingConvention namingConvention = new MatchingNamingConvention(); 

    ServerConfig serverConfig = ... 
    serverConfig.setNamingConvention(namingConvention); 
相关问题