so I want to search one value in 3 columns in the MYSQL table and write JPA query like this:
SELECT * FROM table WHERE 123 IN(col1, col2, col3);
so the problem is col2 and col3 are nullable they may have null value so the type of these columns is Option[String] in the entity class.
so I tried something like this in JpaRepository:
@Repository
trait ContactRepo extends JpaRepository[Contact, Long] {
def findFirstByCol1OrCol2OrCol3(c1: String, c2: scala.Option[String], c3: scala.Option[String]): Contact
}
and while calling this:
val optionData: scala.Option[String] = scala.Option("1234567890")
val someData: scala.Some[String] = scala.Some("12345678980")
val simpleStringData: String = "1234567890"
val contact = contactRepo.findFirstByCol1OrCol2OrCol3(simpleStringData, optionData, optionData)
I tried all variables(optionData, someData and simpleStringData) but I keep getting this error:
Parameter value [1234567890] did not match expected type [scala.Option (n/a)]
I tried OnIsNull also but still not working
I don't know what I'm missing I think its some small mistake that I don't understand
problem: how can i write JPA query for SELECT * FROM table WHERE 123 IN(col1, col2, col3);
Note: type of col2 and col3 are scala.Option[String]