Produced more inefficient sql after using entity cache

Hi,
There is a master entity with several associated entities in my project.
When editing the master entity, the master entity loaded by a entity view, the view looks like :
image

We can see that there are several associated entities should be loaded.
Before using entity cache,the generated sql for loading associated entities looks like:
image

We can see it only load one entity instance for a associated property.

After i enable cache for associated entities ,the generated sql looks like :
image

The cache config looks like :
image

We can see,produced sql load all entity instances of a reference property.
The expected behavior is that query the master entity from database every time , and query the associated entity from database only first time, then the associated entity instances shoud be cached , subsequent editing for master entity should not load associated entity instance through database , shoud load the associated entity from cache.

Environment:
CUBA 7.1.2
MySql

Hi,
Errors with entity cache are difficult to reproduce. Maybe only debugging will help.
Could you provide a sample project which reproduces the error?
We’ll try to find a cause of the error.

Thank you,
Andrey

Hi Andrey,

Thanks for you reply .
I created a testing project based CUBA petclinic project for the problem,see attachment.

In the testing project, the Dict1 entity is cacheable.
I think the Dict1 entity should be queried from database only once . But now it is queried every time when edit owner.

cuba-petclinic.zip (8.0 MB)

Hi, @lugreen!

It seems like there is no bug with caches in the testing project (and supposedly in your project since queries looks the same). Dict1 entities on Owner editor screen queried every time by collection data loader which provides data for LookupPickerField. Entity cache provided by EclipseLink is used only when you retrieve entities by ID, but data loader uses the query select e from petclinic_Dict1 e. This query also could be cached if you enable cache for it, for example using cacheable="true" XML attribute for data loader. See “Query Cache” paragraph from the link before.

Regards,
Sergey

Hi @s.fedorov,

Sorry for long silent .

I will describe more clearly the problem soon.