Created
January 16, 2012 17:12
-
-
Save takezoe/1621843 to your computer and use it in GitHub Desktop.
Trouble in the Anorm Parser Combinator API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// これはOK | |
val result = SQL("SELECT * FROM EMP E INNER JOIN DEPT D ON D.DEPT_ID = E.DEPT_ID ORDER BY EMP_ID") | |
.as(Emp ~< Dept *) | |
// これもOK | |
val result = SQL("SELECT * FROM EMP E " + | |
"INNER JOIN DEPT D ON D.DEPT_ID = E.DEPT_ID " + | |
"ORDER BY EMP_ID").as(Emp ~< Dept *) | |
// これはNG | |
val result = SQL("""SELECT * FROM EMP E | |
INNER JOIN DEPT D ON D.DEPT_ID = E.DEPT_ID | |
ORDER BY EMP_ID""").as(Emp ~< Dept *) | |
/* | |
こんな感じのスタックトレース | |
Execution exception (In /app/controllers/user.scala around line 27) | |
RuntimeException occured : ColumnNotFound(Dept.dept_id) | |
play.exceptions.JavaExecutionException: ColumnNotFound(Dept.dept_id) | |
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:231) | |
at Invocation.HTTP Request(Play!) | |
Caused by: java.lang.RuntimeException: ColumnNotFound(Dept.dept_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.SqlQuery.as(Anorm.scala:938) | |
at controllers.user$.test(user.scala:27) | |
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548) | |
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502) | |
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:496) | |
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473) | |
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161) | |
... 1 more | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AnormがSQLを投げるときにLFを" "に変換してるらしい。それでWindowsで作成したソースだと改行はCRLFだからLFだけ変換されてCRだけ残ってしまいSQLの1行目だけが実行されてしまうとか、そんなくだらない理由のようだ。
http://stackoverflow.com/questions/6869954/columnnotfound-problem-with-magic-in-play-scala