Most likely this happens because, by default, @ManyToOne and @OneToOne associations are using FetchType.EAGER.
So, in your case, you have an entity that was cached. But when you fetch it, it tries to load all EAGER associations as well, which are not cached, like:
EmployeeDepartementAddress
To fix it, you have to options:
-
Either you set all to
FetchType.LAZYfor all these@ManyToOneand@OneToOneassociations@MnyToOne(fetch = FetchType.LAZY) private Employee employee; -
Or, you cache all these entities as well, meaning that you need to provide the Hibernate
@Cacheannotation which provides the cache concurrency strategy:@Entity(name = "Employee") @Cacheable @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class Employee { .... }