问题
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.
回答1:
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_NUMERIC
which will store it in Postgres as NUMERIC
. You'll need to specify it as:
@DatabaseFiled(dataType = BIG_DECIMAL_NUMERIC)
BigDecimal number;
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:
http://ormlite.com/docs/custom-persister
There is also an example project with code which shows how to define a data persister for your custom type:
http://ormlite.com/docs/data-persister-example
来源:https://stackoverflow.com/questions/9965829/map-postgresql-money-data-type-to-ormlite