Last active
August 29, 2015 13:57
-
-
Save seratch/9886310 to your computer and use it in GitHub Desktop.
[scalikejdbc-users-group:149] java.lang.IllegalStateException: Passed named parameter is ignored. ('sName)
This file contains 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
libraryDependencies ++= Seq( | |
"org.scalikejdbc" %% "scalikejdbc" % "1.7.4", | |
"org.scalikejdbc" %% "scalikejdbc-interpolation" % "1.7.4", | |
"com.h2database" % "h2" % "[1.3,)", | |
"ch.qos.logback" % "logback-classic" % "[1.1,)" | |
) |
This file contains 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
scala> DB localTx { implicit session => | |
| val sql = "Update Student SET `sName` = {sName} Where Student.sId = {sId}" | |
| val result = SQL(sql).bindByName(Symbol("sName") -> "Peter", Symbol("sId") -> sId).update().apply | |
| } | |
java.lang.IllegalStateException: Passed named parameter is ignored. ('sName) | |
at scalikejdbc.createNameBindingSQL$$anonfun$validateAndConvertToNormalStatement$1.apply(SQL.scala:114) | |
at scalikejdbc.createNameBindingSQL$$anonfun$validateAndConvertToNormalStatement$1.apply(SQL.scala:108) | |
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) | |
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34) | |
at scalikejdbc.createNameBindingSQL$.validateAndConvertToNormalStatement(SQL.scala:107) | |
at scalikejdbc.createNameBindingSQL$.apply(SQL.scala:148) | |
at scalikejdbc.SQL.bindByName(SQL.scala:226) | |
at $anonfun$1.apply(<console>:18) | |
at $anonfun$1.apply(<console>:16) | |
at scalikejdbc.DBConnection$$anonfun$localTx$1$$anonfun$apply$1.apply(DB.scala:256) | |
at scala.util.control.Exception$Catch.apply(Exception.scala:102) | |
at scalikejdbc.DBConnection$$anonfun$localTx$1.apply(DB.scala:254) | |
at scalikejdbc.DBConnection$$anonfun$localTx$1.apply(DB.scala:251) | |
at scalikejdbc.LoanPattern$.using(LoanPattern.scala:29) | |
at scalikejdbc.package$.using(package.scala:76) | |
at scalikejdbc.DBConnection$class.localTx(DB.scala:251) | |
at scalikejdbc.DB.localTx(DB.scala:498) | |
at scalikejdbc.DB$$anonfun$localTx$2.apply(DB.scala:680) | |
at scalikejdbc.DB$$anonfun$localTx$2.apply(DB.scala:679) | |
at scalikejdbc.LoanPattern$.using(LoanPattern.scala:29) | |
at scalikejdbc.package$.using(package.scala:76) | |
at scalikejdbc.DB$.localTx(DB.scala:679) | |
at .<init>(<console>:16) | |
at .<clinit>(<console>) | |
at .<init>(<console>:7) | |
at .<clinit>(<console>) | |
at $print(<console>) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) |
This file contains 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
import scalikejdbc._, SQLInterpolation._ | |
Class.forName("org.h2.Driver") | |
ConnectionPool.singleton("jdbc:h2:mem:hello", "user", "pass") | |
implicit val session = AutoSession | |
sql"create table student (`sId` serial not null primary key, `sName` varchar(64))".execute.apply() | |
val sId = DB.localTx { implicit s => sql"insert into student (sName) values ('Alice');".updateAndReturnGeneratedKey.apply() } | |
val sName = "Bob" | |
DB localTx { implicit session => | |
val sql = "Update Student SET `sName` = {sName} Where Student.sId = {sId}" | |
val result = SQL(sql).bindByName(Symbol("sName") -> "Peter", Symbol("sId") -> sId).update().apply | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment