Broadleaf Microservices
  • v1.0.0-latest-prod

Extending Auth Entities

When extending out-of-the-box Broadleaf entities in AuthenticationService, a specific Hibernate enhancement plugin configuration is required in the pom.xml to support field-level lazy loading (FetchType.LAZY). Without this plugin configuration, Hibernate cannot process lazy properties properly, causing the extended auth entities to fail at runtime.

Depending on your project setup, this configuration might need to be added manually:

Manifest-Based Projects (New Activation)

If you are using a Manifest-based project (using manifest.yml with the Broadleaf Flex Maven Plugin) and are just now enabling the authComponent, the plugin configuration is automatically injected into the generated authComponent/pom.xml during the code generation process. No manual action is required.

Non-Manifest Projects or Pre-existing Auth Modules

You must manually add the hibernate-enhance-maven-plugin configuration to your authComponent module’s pom.xml under the <build><plugins> section if:

  • You are not using a Manifest-based project structure.

  • You already have a pre-existing, custom-extended authComponent module (as the automated generator avoids overwriting or altering pre-existing POM structures).

Required Maven Plugin Configuration:

<plugin>
    <!--
        IMPORTANT: This plugin configuration is required for extensions against
        Broadleaf Auth entities to work properly.
        This plugin is required to support field-level lazy loading (FetchType.LAZY)
        for out of the box Auth entities. Without this plugin, Hibernate cannot process
        lazy properties properly, which will cause auth extended entities to fail.
     -->
    <groupId>org.hibernate.orm.tooling</groupId>
    <artifactId>hibernate-enhance-maven-plugin</artifactId>
    <executions>
        <execution>
            <configuration>
                <failOnError>true</failOnError>
                <enableLazyInitialization>true</enableLazyInitialization>
                <enableDirtyTracking>true</enableDirtyTracking>
            </configuration>
            <goals>
                <goal>enhance</goal>
            </goals>
        </execution>
    </executions>
</plugin>