javamoney-examples icon indicating copy to clipboard operation
javamoney-examples copied to clipboard

Provide serialization example in the docs for Database storage of MonetaryAmount

Open feinstein opened this issue 7 years ago • 5 comments

Are there any samples on how to save MonetaryAmount on a database? I think this is very common use case, so the docs should include it.

I would at least propose two subtasks to this:

  • [ ] Relational DB via Jadira Extended
  • [ ] Non-Relational DBs via Jakarta NoSQL

feinstein avatar Dec 19 '18 22:12 feinstein

https://github.com/JavaMoney/jsr354-ri/issues/185

You are welcome to send a PR to userguides. Actually the best guides are those which written by users when they had a question.

stokito avatar Dec 19 '18 23:12 stokito

Good point, I am still learning the library, but when I get more comfortable with it I really might submit some guide.

feinstein avatar Dec 20 '18 00:12 feinstein

I would also recommend a general guide on regular SQL, since many people (me included) aren't using any ORMs.

feinstein avatar Dec 20 '18 00:12 feinstein

for general SQL you can store only cents (i.e. minor units) in long columns and then use the Money.ofMinorUnits(cents) method to create the Money instance

stokito avatar Dec 20 '18 16:12 stokito

Oh, interesting, thanks!

feinstein avatar Dec 20 '18 16:12 feinstein