Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why BsonObjectId::apply(String) method does not work for the second time?

Tags:

mongodb

scala

//Below line of code works fine with the result, 
//maxBSONValue: org.mongodb.scala.bson.BsonObjectId = BsonObjectId{value=572865049229f27baf82c974}
val maxBSONValue = org.mongodb.scala.bson.BsonObjectId("572865049229f27baf82c974") 

//Subsequent execution of below line results in error
//error: org.mongodb.scala.bson.BsonObjectId.type does not take parameters
val minBSONValue = org.mongodb.scala.bson.BsonObjectId("572865049229f27baf82c96f")

Why BsonObjectId::apply(String) method does not work for the second time?

like image 617
SunnyShah Avatar asked Jan 17 '26 19:01

SunnyShah


1 Answers

Instead of invoking apply() method from the BsonObjectId companion object (here), it seems to be seeing BsonObjectId as a type (defined here) and it complains that it doesn't take parameters (which is true). This is the cause of your error message. Not sure why it's happening though. Check out this question and see if you can find something useful (I didn't really dig too deep into it).

Sorry for posting as answer even though it isn't really one, but I think it could put you on the right track and I couldn't fit it into comments.

like image 82
slouc Avatar answered Jan 20 '26 10:01

slouc