1. Background: Transactions and Hibernate Sessions


2. Lazy Loading Explained


3. What Happened in Our Code

We added logging inside OfferAdminMapperDecorator:

try {
    loggingService.info(LogPrefix.OFFER, LogLayer.MAPPER,
        "User {} offers size: {}", user.getId(),
        (user.getOffers() == null ? "null" : user.getOffers().size()));
} catch (LazyInitializationException e) {
    loggingService.error(LogPrefix.OFFER, LogLayer.MAPPER,
        "Could not initialize user.getOffers() for user {}: {}", e, user.getId(), e.getMessage());
}

That’s why our logs look like:

Could not initialize user.getOffers() for user [...] failed to lazily initialize a collection

The same thing happened for: