我正在使用Play2.1.1、Postgress和Herkou,并且只从我的生产数据库中获取奇怪的异常。
局部vs H2,一切正常。但是,在生产中,相同的操作失败:

2013-06-14T01:49:25.275717+00:00 app[web.1]: [←[37minfo←[0m] application - 2013-06-14T01:49:25.275Z - Updating cache with new peak 266
2013-06-14T01:49:48.310600+00:00 app[web.1]: [←[37minfo←[0m] application - Updating database with peak 266
2013-06-14T01:49:48.327490+00:00 app[web.1]: [←[31merror←[0m] application -
2013-06-14T01:49:48.327490+00:00 app[web.1]:
2013-06-14T01:49:48.327490+00:00 app[web.1]: ! @6eih9flgb - Internal server error, for (GET) [/updateDB] ->
2013-06-14T01:49:48.327490+00:00 app[web.1]:
2013-06-14T01:49:48.327490+00:00 app[web.1]: play.api.Application$$anon$1: Execution exception[[RuntimeException: TypeDoesNotMatch(Cannot convert 266:
class java.math.BigDecimal to Long for column ColumnName(peaks.price,Some(price)))]]
2013-06-14T01:49:48.327490+00:00 app[web.1]:    at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10-2.1.0.jar:2.1.0]
2013-06-14T01:49:48.327490+00:00 app[web.1]:    at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10-2.1.0.jar:2.1.0]
2013-06-14T01:49:48.327490+00:00 app[web.1]:    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$12$$anonfun$apply$24.apply(PlayDefaultUp
streamHandler.scala:314) [play_2.10-2.1.0.jar:2.1.0]
2013-06-14T01:49:48.327490+00:00 app[web.1]:    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$12$$anonfun$apply$24.apply(PlayDefaultUp
streamHandler.scala:312) [play_2.10-2.1.0.jar:2.1.0]
2013-06-14T01:49:48.327490+00:00 app[web.1]:    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10-2.1.0.j
ar:2.1.0]
2013-06-14T01:49:48.327660+00:00 app[web.1]:    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10-2.1.0.j
ar:2.1.0]
2013-06-14T01:49:48.327660+00:00 app[web.1]: java.lang.RuntimeException: TypeDoesNotMatch(Cannot convert 266:class java.math.BigDecimal to Long for co
lumn ColumnName(peaks.price,Some(price)))
2013-06-14T01:49:48.322664+00:00 heroku[router]: at=info method=GET path=/updateDB host=www.bitcoinpeak.org fwd="84.94.173.221" dyno=web.1 connect=2ms
 service=2019ms status=500 bytes=1941
2013-06-14T01:49:48.327660+00:00 app[web.1]:    at scala.sys.package$.error(package.scala:27) ~[scala-library.jar:na]
2013-06-14T01:49:48.327660+00:00 app[web.1]:    at anorm.Sql$.as(Anorm.scala:535) ~[anorm_2.10-2.1.0.jar:2.1.0]
2013-06-14T01:49:48.327660+00:00 app[web.1]:    at anorm.Sql$class.executeInsert(Anorm.scala:474) ~[anorm_2.10-2.1.0.jar:2.1.0]
2013-06-14T01:49:48.327660+00:00 app[web.1]:    at anorm.SimpleSql.executeInsert(Anorm.scala:370) ~[anorm_2.10-2.1.0.jar:2.1.0]
2013-06-14T01:49:48.327660+00:00 app[web.1]:    at org.bitcoinpeak.Peak$$anonfun$addPeak$1.apply(Peak.scala:43) ~[bitcoin-peak_2.10-1.0-SNAPSHOT.jar:1
.0-SNAPSHOT]
2013-06-14T01:49:48.327660+00:00 app[web.1]:    at org.bitcoinpeak.Peak$$anonfun$addPeak$1.apply(Peak.scala:40) ~[bitcoin-peak_2.10-1.0-SNAPSHOT.jar:1
.0-SNAPSHOT]
2013-06-14T01:50:24.933750+00:00 app[web.1]: [←[37minfo←[0m] application - 2013-06-14T01:50:24.933Z - Updating cache with new peak 266
2013-06-14T01:51:24.796588+00:00 app[web.1]: [←[37minfo←[0m] application - 2013-06-14T01:51:24.796Z - Updating cache with new peak 266
2013-06-14T01:51:40.719105+00:00 heroku[router]: at=info method=HEAD path=/ host=www.bitcoinpeak.org fwd="74.86.158.106" dyno=web.1 connect=1ms servic
e=7ms status=404 bytes=1900
2013-06-14T01:52:25.047381+00:00 app[web.1]: [←[37minfo←[0m] application - 2013-06-14T01:52:25.047Z - Updating cache with new peak 266
2013-06-14T01:52:33.646553+00:00 heroku[router]: at=info method=GET path=/ host=www.bitcoinpeak.org fwd="74.86.158.107" dyno=web.1 connect=2ms service
=21ms status=200 bytes=1892
2013-06-14T01:53:25.420489+00:00 app[web.1]: [←[37minfo←[0m] application - 2013-06-14T01:53:25.420Z - Updating cache with new peak 266

生产表如下所示:
> \d+ Peaks
                                         Table "public.peaks"
 Column |            Type             |       Modifiers        | Storage | Stats target | Description
--------+-----------------------------+------------------------+---------+--------------+-------------
 price  | numeric(20,0)               | not null               | main    |              |
 time   | timestamp without time zone | not null default now() | plain   |              |

为什么在本地工作的代码在生产中会失败?
是SQL风格吗?我怎样才能修好它?
奇怪的是,我试图做的事务(插入一行)确实起作用——行被添加。那么,这个例外从何而来呢?
整个项目is one github,如果有人需要更多的上下文。
更新:案例类:
import java.math.BigDecimal
import org.joda.time.DateTime

case class Peak(
  time: DateTime,
  price: BigDecimal
)

最佳答案

在使用不同的数据库系统时,我看到了类似的问题。因此,我建议您检查数据库版本、配置、表的DDL和用于细微差别的JDBC驱动程序,这些细微差别使列在一种情况下显示为BigDecimal,在另一种情况下显示为Long。
你也可以看看这张票:http://play.lighthouseapp.com/projects/82401/tickets/243-weird-typedoesnotmatch-exception-in-rc-3-and-final
似乎有一个问题,列的顺序和某些版本的发挥。

07-24 09:47