What type of data I should define on my java model for PostgreSQL money type?
I know I could use BigDecimal, but it map to varchar(255) on PostgreSQL.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think that @a_horse’s comment provides some good information but I thought I’d add some additional ORMLite’s specific details.
You could use ORMLite’s
BIG_DECIMAL_NUMERICwhich will store it in Postgres asNUMERIC. You’ll need to specify it as:If you are set on using the money type, then you can define your own custom persister. You can date a look at the documentation that front:
There is also an example project with code which shows how to define a data persister for your custom type: