Uploaded image for project: 'Hibernate ORM'
  1. HHH-12484

Improved error output for LazyInitializationException to include entity-related info

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.3.11, 5.2.16
    • Fix Version/s: 5.2.17, 5.3.0.CR2
    • Component/s: hibernate-core
    • Labels:
      None

      Description

      AbstractLazyInitializer.initialize() can throw LazyInitializationExceptions:

      if (this.session == null) {
          throw new LazyInitializationException("could not initialize proxy - no Session");
      }
      
      if (!this.session.isOpen()) {
          throw new LazyInitializationException("could not initialize proxy - the owning Session was closed");
      }
      
      if (!this.session.isConnected()) {
          throw new LazyInitializationException("could not initialize proxy - the owning Session is disconnected");
      }

      I think it would greatly make debugging easier when entityName and ID of the entity would be included in all lazyinitialization exception messages to give a clue in the right direction.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: