Nadav Leshem
Nadav Leshem

Reputation: 193

Mapping Java beans and Scala case classes to MongoDB objects

I am currently struggling with this issue here..

In our system, we use Java beans and Scala case classes, and they often contains one another. So, i am looking for a good solution for how to map these objects to mongoObjects, so i can save/load them from the database.

For this, i tried Morphia, but unfortunately it won't serialize back from json to object because it cannot construct a case class.

So I tried Salat, but this one only works with case classes and not java beans :(

Do anyone have an idea about how to do this?

Upvotes: 2

Views: 930

Answers (1)

prasinous
prasinous

Reputation: 798

Salat developer here.

If you want to use Salat, you could convert your Java beans to Scala case classes and annotate the constructor params with @scala.reflect.BeanProperty for interoperability with Java (if this is really necessary).

Upvotes: 1

Related Questions