0

I stored a data in jsonb column:

@Entity
public class Car {
    @Id
    private Long id;

    @Type(type = "jsonb")
    private Data data;
}

Example of structure

{
    "id": 1,
    "car": "mersedes",
    "count": 100,
    "stores" : [{
        "city": "LA",
        "country": "USA",
        "brands": [{
            "name": "CLS",
            "count": 14
        },
        {
            "name": "C-class",
            "count": 17
        }]
    }]
}

a file takes more than 700mB of memory and I don't want to load all the data into RAM, I need to get data only by filters, for example get only CLS model. can this be done with jpa specification?

And if I want to getting only adderesses how to ignore brands? how to get from the original json like this:

 { 
      "stores" : [{
        "city": "LA",
        "country": "USA"
      ]}
 }
AbrA
  • 434
  • 1
  • 6
  • 19
  • JPA: https://stackoverflow.com/questions/59628543/jpa-specification-to-filter-entries-based-on-a-key-in-the-jsonb-map and Native query: https://stackoverflow.com/questions/54006818/how-to-filter-jsonb-array-elements – Arun Sudhakaran Feb 20 '23 at 05:28

0 Answers0