Class SpringPersistenceUnitInfo

java.lang.Object
org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo
org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo

public class SpringPersistenceUnitInfo extends MutablePersistenceUnitInfo
Subclass of MutablePersistenceUnitInfo that adds instrumentation hooks based on Spring's LoadTimeWeaver abstraction.

As of 7.0, this class is public for custom bootstrapping purposes. A fully configured SpringPersistenceUnitInfo instance can be turned into a standard JPA descriptor through asStandardPersistenceUnitInfo() (returning a JPA 3.2/4.0 adapted proxy).

Note: For post-processing within a LocalContainerEntityManagerFactoryBean bootstrap, the base type MutablePersistenceUnitInfo is entirely sufficient.

Since:
7.0
Author:
Rod Johnson, Juergen Hoeller, Costin Leau
See Also:
  • Constructor Details

    • SpringPersistenceUnitInfo

      public SpringPersistenceUnitInfo(LoadTimeWeaver loadTimeWeaver)
      Construct a new SpringPersistenceUnitInfo for custom purposes.
      Parameters:
      loadTimeWeaver - the LoadTimeWeaver to use
    • SpringPersistenceUnitInfo

      public SpringPersistenceUnitInfo(ClassLoader classLoader)
      Construct a new SpringPersistenceUnitInfo for custom purposes.
      Parameters:
      classLoader - the ClassLoader to use
  • Method Details

    • getClassLoader

      public @Nullable ClassLoader getClassLoader()
      This implementation returns the LoadTimeWeaver's instrumentable ClassLoader, if specified.
    • addTransformer

      public void addTransformer(jakarta.persistence.spi.ClassTransformer classTransformer)
      This implementation delegates to the LoadTimeWeaver, if specified.
    • getNewTempClassLoader

      public ClassLoader getNewTempClassLoader()
      This implementation delegates to the LoadTimeWeaver, if specified.
    • setScopeAnnotationName

      public void setScopeAnnotationName(@Nullable String scopeAnnotationName)
    • getScopeAnnotationName

      public @Nullable String getScopeAnnotationName()
    • addQualifierAnnotationName

      public void addQualifierAnnotationName(String qualifierAnnotationName)
    • getQualifierAnnotationNames

      public List<String> getQualifierAnnotationNames()
    • apply

      public void apply(PersistenceManagedTypes managedTypes)
      Apply the given PersistenceManagedTypes to this persistence unit, typically coming from Spring AOT.
      Parameters:
      managedTypes - the managed persistent types to register
      Since:
      7.0
    • apply

      public void apply(jakarta.persistence.PersistenceConfiguration config, DataSourceLookup dataSourceLookup)
      Apply the given JPA 3.2 PersistenceConfiguration to this persistence unit, copying all applicable settings.

      Beyond the standard PersistenceConfiguration settings, "rootUrl" and "jarFileUrls" from HibernatePersistenceConfiguration are also detected and applied.

      Parameters:
      config - the JPA persistence configuration to apply
      dataSourceLookup - the JDBC DataSourceLookup that provides DataSources for the persistence provider, resolving data source names in PersistenceConfiguration against Spring-managed DataSource instances
      Since:
      7.0
    • asStandardPersistenceUnitInfo

      public jakarta.persistence.spi.PersistenceUnitInfo asStandardPersistenceUnitInfo()
      Expose a standard jakarta.persistence.spi.PersistenceUnitInfo proxy for the persistence unit configuration in this SpringPersistenceUnitInfo instance.

      The returned proxy implements jakarta.persistence.spi.PersistenceUnitInfo (and its extended variant SmartPersistenceUnitInfo) for use with persistence provider bootstrapping. Note that the returned proxy is effectively unmodifiable and cannot be downcast to Mutable/SpringPersistenceUnitInfo.