Quarkus / hibernate-orm caching of collections (@OneToMany)

419 Views Asked by At

I have to objects (Garage,Car) as it's described bellow . My questions is why when I try to access something like Garage.cars on my endpoints logic , the field "cars" from Garage is queried from database (insead of the cache) , even if in configuration file I set up the property quarkus.hibernate-orm.cache."org.acme.Garage#cars".expiration.max-idle = 86400 (Garage.cars) cache expires after 100 seconds (what I want is to set this to 86400) I just want to ask if it is a normal flow or maybe anyone has been struggling with the same problem .

My entities looks like this :

@Entity @Table(name="GarageTable") @Cacheable @ApplicationScoped

public class Garage extends PanacheEntityBase {

@Id
@Column(name = "GarId")
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long garageId;

@ManyToMany()
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@JoinTable(name="garage_cars" , joinColumns = @JoinColumn(name = "garage_id") , inverseJoinColumns = @JoinColumn(name = "car_id"))
public Set<Car> cars;

@Column(name="GarageDimension" , length = 10)
public Long dimension;

public static Garage findGarageById(Long id) {
    return findById(id);
}
@Override
public String toString() {
    return "Garage [garageId=" + garageId + ", cars=" + cars + ", dimension=" + dimension + "]";
}

}

0

There are 0 best solutions below