playframework - Error:could not find implicit value for parameter p: scala.slick.jdbc.SetParameter[java.util.UUID] -
inserting row in postgres database table using scala produce following error.
could not find implicit value parameter p: scala.slick.jdbc.setparameter[java.util.uuid]
signupprocess.scala
case class signupprocess(subscriber_uuid:uuid,firstname:string,lastname:string,jobtitle:string,phone:string,email:string,password:string,company_name:string,no_of_employees:int,my_schema_name:string,my_date:date,my_time:time) object signupprocess{ // _ip -> input parameter def signup(firstname_ip: string, lastname_ip: string, jobtitle_ip: string, phone_ip: string, email_ip: string, password_ip: string, companyname_ip: string, employeescount_ip: int) : string = { database.forurl("jdbc:postgresql://localhost:5432/my_db", "postgres", "mypassword",null, driver="org.postgresql.driver") withsession{ def insert(c: signupprocess) = (q.u + "insert my_schema.my_table(subscriber_uuid,firstname,lastname,jobtitle,phone,email,password,company_name,no_of_employees,my_schema_name,my_date,my_time) values( '"+? c.subscriber_uuid+"', "+? c.firstname+","+? c.lastname+","+? c.jobtitle+","+? c.phone+","+? c.email+","+? c.password+","+? c.company_name+","+? c.no_of_employees+","+? c.my_schema_name+","+? c.my_date+","+? c.my_time+")").execute seq( signupprocess(uuid.randomuuid(), firstname_ip, lastname_ip, jobtitle_ip, phone_ip, email_ip, password_ip, companyname_ip, 10, "mymail_gmail_com", new date(2013,8,8), new time(16,30,0)) ).foreach(insert) "success" } } }
slick not know how set uuid
instance query. try adding uuid
query c.subscriber_uuid.tostring
instead.
you missing implicit session
on withsession
. modified example of code compiles follows:
import java.util.uuid import java.sql.date import java.sql.time import scala.slick.session.database import scala.slick.jdbc.{staticquery => q} case class signupprocess(subscriber_uuid:uuid,firstname:string,lastname:string,jobtitle:string,phone:string,email:string,password:string,company_name:string,no_of_employees:int,my_schema_name:string,my_date:date,my_time:time) object signupprocess{ // _ip -> input parameter def signup(firstname_ip: string, lastname_ip: string, jobtitle_ip: string, phone_ip: string, email_ip: string, password_ip: string, companyname_ip: string, employeescount_ip: int) : string = { database.forurl("jdbc:postgresql://localhost:5432/my_db", "postgres", "mypassword",null, driver="org.postgresql.driver") withsession{ implicit session => def insert(c: signupprocess) = (q.u + "insert my_schema.my_table(subscriber_uuid,firstname,lastname,jobtitle,phone,email,password,company_name,no_of_employees,my_schema_name,my_date,my_time) values( '"+? c.subscriber_uuid.tostring+"', "+? c.firstname+","+? c.lastname+","+? c.jobtitle+","+? c.phone+","+? c.email+","+? c.password+","+? c.company_name+","+? c.no_of_employees+","+? c.my_schema_name+","+? c.my_date+","+? c.my_time+")").execute seq( signupprocess(uuid.randomuuid(), firstname_ip, lastname_ip, jobtitle_ip, phone_ip, email_ip, password_ip, companyname_ip, 10, "mymail_gmail_com", new date(2013,8,8), new time(16,30,0)) ).foreach(insert) "success" } } }
Comments
Post a Comment