Hi,
we are building a kotlin application which is based on springboot3.5.6 + hibernate6
and we are facing an LinkedHashMap ordering issue
we have an objects which is stored in postgresql14
@JdbcTypeCode(SqlTypes.JSON)
@Column(name = "compound_rules", columnDefinition = "json")
var compoundRules: LinkedHashMap<String, CompoundRuleData>,
in the database side columsn are properly defined as “json” type and not “jsonb”
and it seems that the order of the compoundRules elements , which should be element insertion order is not kept.
tracing log information shows that the PGStatement is properly created and the following Release message is printed (note the ids order)
2025-11-09 12:21:47,140 [TRACE] [http-nio-8080-exec-4] [opId=ae543957aff2] [userEmail=admin@fmanager.com] [ResourceRegistryStandardImpl.java:96] Releasing statement [/* update for com.foretellix.manager.services.workspace.WorkspaceCompoundRulesData */update workspace_compound_rules set compound_rules=(‘{“4d3f85b4962c50fd7f38”:{“id”:“4d3f85b4962c50fd7f38”,“name”:“test_rule_0”,“modifiedAt”:1762683706,“lastModifiedById”:“42e6b2f773365a5fae82”,“createdById”:“42e6b2f773365a5fae82”,“rulesParams”:{“temporalRelationParams”:{“intervalFilters”:[{“elements”:[{“_type”:“intervals”,“include”:true,“scenarioName”:null,“protected”:false,“logicalOperator”:“AND”,“intervalName”:“sut.lead_vehicle”,“intervalType”:“MatchIntervalData”,“childrenFilter”:null,“intervalCriteria”:}],“logicalOperator”:“AND”,“isEmpty”:false},{“elements”:[{“_type”:“intervals”,“include”:true,“scenarioName”:null,“protected”:false,“logicalOperator”:“AND”,“intervalName”:“sut.follower_vehicle”,“intervalType”:“MatchIntervalData”,“childrenFilter”:null,“intervalCriteria”:}],“logicalOperator”:“AND”,“isEmpty”:false}],“timeRelation”:“ANY_INTERSECTION”,“customTimeRelation”:null,“workspaceId”:“4a4cafc9c441ec77fc08”},“temporalAction”:“UNION”,“nameParams”:{“name”:“test_interval”,“concatNames”:false,“delimiter”:“_”},“metricGroupPrefix”:null,“corrMetricGroupPrefix”:null},“creationContext”:“WORKSPACE”,“createdAt”:1762683706},“414981a5b9d77c76829a”:{“id”:“414981a5b9d77c76829a”,“name”:“test_rule_1”,“modifiedAt”:1762683707,“lastModifiedById”:“42e6b2f773365a5fae82”,“createdById”:“42e6b2f773365a5fae82”,“rulesParams”:{“temporalRelationParams”:{“intervalFilters”:[{“elements”:[{“_type”:“intervals”,“include”:true,“scenarioName”:null,“protected”:false,“logicalOperator”:“AND”,“intervalName”:“sut.lead_vehicle”,“intervalType”:“MatchIntervalData”,“childrenFilter”:null,“intervalCriteria”:}],“logicalOperator”:“AND”,“isEmpty”:false},{“elements”:[{“_type”:“intervals”,“include”:true,“scenarioName”:null,“protected”:false,“logicalOperator”:“AND”,“intervalName”:“sut.follower_vehicle”,“intervalType”:“MatchIntervalData”,“childrenFilter”:null,“intervalCriteria”:}],“logicalOperator”:“AND”,“isEmpty”:false}],“timeRelation”:“ANY_INTERSECTION”,“customTimeRelation”:null,“workspaceId”:“4a4cafc9c441ec77fc08”},“temporalAction”:“UNION”,“nameParams”:{“name”:“test_interval”,“concatNames”:false,“delimiter”:“_”},“metricGroupPrefix”:null,“corrMetricGroupPrefix”:null},“creationContext”:“WORKSPACE”,“createdAt”:1762683707}}’),version=(‘2’::int4),workspace_id=(‘4a4cafc9c441ec77fc08’) where id=(‘4643b0cbd1fce539cc70’)]
however, if looking at the postgresql log message exactly at that timestamp we will see that the order of elements is reversed (note again the ids)
2025-11-09 12:21:47.140 IST [3182906] fmanager@fmanager LOG: execute : /* update for com.foretellix.manager.services.workspace.WorkspaceCompoundRulesData */update workspace_compound_rules set compound_rules=$1,version=$2,workspace_id=$3 where id=$4
2025-11-09 12:21:47.140 IST [3182906] fmanager@fmanager DETAIL: parameters: $1 = ‘{“414981a5b9d77c76829a”: {“id”: “414981a5b9d77c76829a”, “name”: “test_rule_1”, “createdAt”: 1762683707, “modifiedAt”: 1762683707, “createdById”: “42e6b2f773365a5fae82”, “rulesParams”: {“nameParams”: {“name”: “test_interval”, “delimiter”: “_”, “concatNames”: false}, “temporalAction”: “UNION”, “metricGroupPrefix”: null, “corrMetricGroupPrefix”: null, “temporalRelationParams”: {“workspaceId”: “4a4cafc9c441ec77fc08”, “timeRelation”: “ANY_INTERSECTION”, “intervalFilters”: [{“isEmpty”: false, “elements”: [{“_type”: “intervals”, “include”: true, “protected”: false, “intervalName”: “sut.lead_vehicle”, “intervalType”: “MatchIntervalData”, “scenarioName”: null, “childrenFilter”: null, “logicalOperator”: “AND”, “intervalCriteria”: }], “logicalOperator”: “AND”}, {“isEmpty”: false, “elements”: [{“_type”: “intervals”, “include”: true, “protected”: false, “intervalName”: “sut.follower_vehicle”, “intervalType”: “MatchIntervalData”, “scenarioName”: null, “childrenFilter”: null, “logicalOperator”: “AND”, “intervalCriteria”: }], “logicalOperator”: “AND”}], “customTimeRelation”: null}}, “creationContext”: “WORKSPACE”, “lastModifiedById”: “42e6b2f773365a5fae82”}, “4d3f85b4962c50fd7f38”: {“id”: “4d3f85b4962c50fd7f38”, “name”: “test_rule_0”, “createdAt”: 1762683706, “modifiedAt”: 1762683706, “createdById”: “42e6b2f773365a5fae82”, “rulesParams”: {“nameParams”: {“name”: “test_interval”, “delimiter”: “_”, “concatNames”: false}, “temporalAction”: “UNION”, “metricGroupPrefix”: null, “corrMetricGroupPrefix”: null, “temporalRelationParams”: {“workspaceId”: “4a4cafc9c441ec77fc08”, “timeRelation”: “ANY_INTERSECTION”, “intervalFilters”: [{“isEmpty”: false, “elements”: [{“_type”: “intervals”, “include”: true, “protected”: false, “intervalName”: “sut.lead_vehicle”, “intervalType”: “MatchIntervalData”, “scenarioName”: null, “childrenFilter”: null, “logicalOperator”: “AND”, “intervalCriteria”: }], “logicalOperator”: “AND”}, {“isEmpty”: false, “elements”: [{“_type”: “intervals”, “include”: true, “protected”: false, “intervalName”: “sut.follower_vehicle”, “intervalType”: “MatchIntervalData”, “scenarioName”: null, “childrenFilter”: null, “logicalOperator”: “AND”, “intervalCriteria”: }], “logicalOperator”: “AND”}], “customTimeRelation”: null}}, “creationContext”: “WORKSPACE”, “lastModifiedById”: “42e6b2f773365a5fae82”}}’, $2 = ‘2’, $3 = ‘4a4cafc9c441ec77fc08’, $4 = ‘4643b0cbd1fce539cc70’
what can be the cause of this

