Reputation: 4174
The Unexpected UnexpectedNullableFound(post.IMAGE) i got this error while running the program, and couldn't identify what is the error , If anyone got the same error or know the detail of the error please mention here
and my database is MySql
My Model class ,
case class Post(id: Pk[Long]= NotAssigned, name:String, image:String)
The function
def listAllPostById():List[Post]={
DB.withConnection{ implicit connection =>
val listpost =SQL(
"""
select * from POST
""").on(
).as(Post.simple.*)
listpost
}
in application the method calling
def listAllpost()= Action{
val post:List[Post]=Post.listAllPostById
Ok(views.html.allPosts.render(post))
}
and in routes
GET /allPosts controllers.Application.listAllpost
And View page
@for(post:Post<- posts){
@post.id
@post.name
@post.image}
Simple method
val simple ={
get[Pk[Long]]("post.id") ~
get[String]("post.name")~
get[String]("post.image") map {
case id ~ name ~ image => Post(id,name,image)
}
Error
Execution exception
[RuntimeException: UnexpectedNullableFound(post.IMAGE)]
Error on line
).as(Post.simple.*)
advnce thnx.. by prasanth
Upvotes: 1
Views: 1374
Reputation: 1016
I think there is error in your simple method. You must take care about your table name and column name, and type of column which you fetched from DB in simple function. In case if you are not sure that row have values for all columns or not you should use Option so may be there you catch this error due to unavailability of data.
You should ensure in simple function about get[DATA TYPE] or get[Option[DATA TYPE]]
Upvotes: 3