Search code examples
javaebeanjava-money

Ebean can't serialize Money


I try to switch my Java pet-project from hand-written SQL to Ebean. When I run the project now I get the message

Was unable to use reflection to find a constructor and appropriate getters forimmutable type interface j`avax.money.MonetaryAmount`

followed by more javamoney-related errors.

I know MonetaryAmont has a private constructor and is instanciated via a public static method. How do I tell Ebean how to serialize a MonetaryAmount?


Solution

  • I've given up on Ebean and used Eclipselink instead. Ironically, that's where I found the answer to my question. So for people in a similar situation as I was here is what I should have done:

    The thing I was looking for is called a ScalarTypeConverter. They are not very well documented in Ebean. However there is some javadoc and at least one issue on GitHub about them.

    Implementing Serializable is not needed in Ebean