CouchbaseTemplate LinkedHashMap @Field insert order not respected

I defined a LinkedHashMap Field:
@Field(“circle_posts_map”)
private LinkedHashMap<String,CirclePostsData> circlePostsMap;

I traced the insert order in my logger and I noticed that the insert order was changed when viewing/retrieving the document.

I used the save method of the CouchbaseTemplate for adding my document to the database.

org.springframework-version 4.1.4.RELEASE
com.couchbase.client-version 1.4.4
spring-data-couchbase-version 1.2.2.RELEASE

I am also facing the same issue. Have you got any solution to this?

Hi @JAGATDEEP_PATTNAIK
The map is being serialized into a JSON object before being stored in Couchbase, and JSON objects are not guaranteed to maintain ordering. If you’re relying on a particular ordering you either need to do that yourself in the application, or use a data structure that will map to a JSON array instead.