Play Scala中Magic的ColumnNotFound问题 [英] ColumnNotFound problem with Magic in play scala

查看:84
本文介绍了Play Scala中Magic的ColumnNotFound问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个"play.exceptions.JavaExecutionException: 尝试在一段代码中找到"ColumnNotFound(comments.id)" 迁移到MySql而不是memorydb. Magic对Postgres的支持是 几乎为空. 演变:

I'm getting a "play.exceptions.JavaExecutionException: ColumnNotFound(comments.id)" in a piece of code after trying to migrate to MySql instead of the memorydb. Postgres support by Magic is almost null. The evolution:

create table comments ( 
    id bigint(20) NOT NULL AUTO_INCREMENT, 
    source varchar(255) NOT NULL, 
    target varchar(255) NOT NULL, 
    content text NOT NULL, 
    date bigint NOT NULL, 
    PRIMARY KEY (id) 
); 

模型:

case class comments(id: Pk[Long], source: String, target: String, 
content: String, date: Long) { 
  override def toString = "|%s| |%s|, |%s|, |%s|".format(id.toString, 
source, target, content) 
  lazy val formattedDate = new SimpleDateFormat("dd.MM.yyyy HH:mm") 
format date 
} 

object comments extends Magic[comments] 

代码段:

def loadComments(username: String) = SQL("""select c.*, u.* from 
comments c, usr u where c.source = u.ccall and c.target = {ccall} 
order by c.date desc""").on("ccall" -> username).as(comments ~< usr *) 

有人可以给我一些建议吗?我真的很坚持..这是stacktrace:

Can anyone give me some pointers? I'm really stuck on this.. Here is the stacktrace:

play.exceptions.JavaExecutionException: ColumnNotFound(comments.id)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:228)
    at Invocation.HTTP Request(Play!)
Caused by: java.lang.RuntimeException: ColumnNotFound(comments.id)
    at scala.Predef$.error(Predef.scala:58)
    at play.db.anorm.Sql$.as(Anorm.scala:984)
    at play.db.anorm.Sql$class.as(Anorm.scala:919)
    at play.db.anorm.SimpleSql.as(Anorm.scala:829)
    at controllers.Profile$.loadacomments(Profile.scala:21)
    at controllers.Profile$.loadacommentsWithLikes(Profile.scala:46)
    at controllers.Profile$.comment(Profile.scala:91)
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:543)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:499)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:493)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:470)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:158)

谢谢!

推荐答案

在此特定情况下,mysql驱动程序是一个旧的驱动程序,使名称看起来真的很奇怪.我刚刚更新了驱动程序,一切恢复原状.

On this specific case, the mysql driver was an old one that made the names look really strange. I just updated the driver and everything came back to place.

您可以在此处查看Google网上论坛中的主题:

You can check the thread in google groups here: http://groups.google.com/group/play-framework/browse_thread/thread/3bd8d3ccb5a51d10/e7074ad34ac637da?lnk=gst&q=Jos%C3%A9+Leal#e7074ad34ac637da

这篇关于Play Scala中Magic的ColumnNotFound问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆