Reputation: 1047
I am using mongoDB database with spring data. Is there an equivalent to hibernate annotation @Type(type = "serializable")
in spring data for mongo?
Upvotes: 4
Views: 4906
Reputation: 15086
Spring data mongo will transparently bind byte[]
to mongo BinData, without a need for any annotation.
If this is not enough for you, you can write custom converter for your type:
http://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongo.custom-converters
However having binary blob doesn't allow any querying or aggregation on the data, so it is usually better to have it in "json" form.
Upvotes: 1