Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class java.math.BigDecimal cannot be cast to class scala.math.BigDecimal in schema-bson #663

Open
bsaletti opened this issue Feb 23, 2024 · 0 comments

Comments

@bsaletti
Copy link

Hello,

I'm trying to make a rest api with zio ecosystem and mongoDB.

When I tring to encode scala.math.BigDecimal in mongoDB, I have this error =>

class java.math.BigDecimal cannot be cast to class scala.math.BigDecimal (java.math.BigDecimal is in module java.base of loader 'bootstrap'; scala.math.BigDecimal is in unnamed module of loader 'app')

I changed
case StandardType.BigDecimalType => BsonCodec.bigDecimal.asInstanceOf[BsonCodec[A]]
to
case StandardType.BigDecimalType => BsonCodec.javaBigDecimal.asInstanceOf[BsonCodec[A]]

case StandardType.BigDecimalType => BsonCodec.bigDecimal.asInstanceOf[BsonCodec[A]]

And this solved the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant