eq operator not found

59 views
Skip to first unread message

Abu Rashid Ibrahim

unread,
Jun 26, 2020, 9:06:38 AM6/26/20
to kmongo
Hi, I am just tryin to follow the initial tutorial code and am getting an error thart the eq function is not found, used as an infix call to findOne().

Is there something I need to add a reference to or import for this? I can see eq in org.litote.kmongo.MongoOperator but that seems to be an enum not a function.

Code is just straight off your intro page:

import org.litote.kmongo.* //NEEDED! import KMongo extensions

data class Jedi(val name: String, val age: Int)

val client = KMongo.createClient() //get com.mongodb.MongoClient new instance
val database = client.getDatabase("test") //normal java driver usage
val col = database.getCollection<Jedi>()

col.insertOne(Jedi("Luke Skywalker", 19))
val yoda : Jedi? = col.findOne(Jedi::name eq "Yoda")  

Thanks,
Abu Rashid.

zigzago

unread,
Jun 26, 2020, 2:40:13 PM6/26/20
to kmongo
Hi,


You can try
import org.litote.kmongo.eq

but * should work too.

HTH

Abu Rashid Ibrahim

unread,
Jun 26, 2020, 9:13:06 PM6/26/20
to kmongo
Doesn't exist for me. I'm using 3.6.2, is that why?

When I try to use 4.0.2 I get the error:

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option

zigzago

unread,
Jun 27, 2020, 4:12:19 AM6/27/20
to kmongo
In kmongo doc:

Starting from 4.0, minimum supported jvm is now 1.8 (was 1.6). You have to set the property jvmTarget to 1.8 (or more) in your gradle or maven descriptor

Abu Rashid Ibrahim

unread,
Jun 27, 2020, 4:56:02 AM6/27/20
to kmongo
Thank you kindly, that has resolved the issue.

I tried searching for this on google but all resolutions I could find were for Android only, and therefore didn't work for me.

Reply all
Reply to author
Forward
0 new messages