Bytecode-enhanced byte[] getter unexpectedly loads other non-requested byte[] fields

Description

With bytecode enhancement active, create an entity with TWO lazy byte[] array fields:

When loading an entity, the LAZY fields aren't loaded. However, calling *any of the byte[] getters* will load + initialize more than the requested byte[] field. Instead, see example, the other field also gets loaded.

This is a problem for entities that have a thumbnail image to be displayed, e.g. in a list on the UI. You will need the thumbnails there, however *NOT* the full image due to performance reasons.

I will create a PR including the test case soon.

Excerpt from the test case:

Excerpt from the debug log, running `gradlew --debug test`:

As you can see, `getThumbnail()` also loads the full image byte[]... which is wrong.

Environment

Hibernate ORM, test suite

Activity

Show:
Andrea Boriero
April 7, 2021, 8:28 AM

Hi ,

actually this is the expected behaviour for all singular attributes as stated here in the doc

By default, all singular attributes are part of a single group, meaning that when one lazy singular attribute is accessed all lazy singular attributes are loaded

in order to obtain what you want you need to use the@LazyGroup annotation.

Ka Wu
April 4, 2021, 6:12 PM

PR here:

This issue must/should be backported to at least 5.2.19.Final. I will likely have another issue there, which doesn’t happen for 5.4.x.

Rejected

Assignee

Unassigned

Reporter

Ka Wu

backPortable

Backport?