Bytecode enhancement should help, but maybe you didn't configure it correctly or the Hibernate version you are using has a bug. I'd need to know details or see a reproducing test case to help you with that.
You could try to use java.sql.Blob
instead which is guaranteed to be lazy and doesn't require byte code enhancement.
Apart from that, I would recommend you use DTO projections for actually fetching just the data that you need. I think this is a perfect use case for Blaze-Persistence Entity Views.
I created the library to allow easy mapping between JPA models and custom interface or abstract class defined models, something like Spring Data Projections on steroids. The idea is that you define your target structure(domain model) the way you like and map attributes(getters) via JPQL expressions to the entity model.
A DTO model for your use case could look like the following with Blaze-Persistence Entity-Views:
@EntityView(Reports.class)
public interface ReportsDto {
@IdMapping
int getId();
String getReportName();
Date getCreatedDate();
Set<ReportRowDto> getRows();
@EntityView(ReportRows.class)
interface ReportRowDto {
@IdMapping
Long getId();
String getName();
}
}
Querying is a matter of applying the entity view to a query, the simplest being just a query by id.
ReportsDto a = entityViewManager.find(entityManager, ReportsDto.class, id);
The Spring Data integration allows you to use it almost like Spring Data Projections: https://persistence.blazebit.com/documentation/entity-view/manual/en_US/index.html#spring-data-features
The DTO projection is validated against the entity model and it will only fetch what is necessary. Spring Data Projections falls back to "just" wrapping entities when the projection is too complex, whereas Blaze-Persistence Entity-Views will alter the query as if you had written it by hand :)