Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColumnNotFound problem with Magic in play scala

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) 
); 

The model:

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] 

And the piece of code:

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 *) 

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)

Thank you!

like image 657
José Leal Avatar asked Nov 04 '22 17:11

José Leal


1 Answers

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.

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

like image 125
José Leal Avatar answered Nov 09 '22 07:11

José Leal