Package org.springframework.orm.jpa.persistenceunit

# Class MutablePersistenceUnitInfo

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

All Implemented Interfaces:
  `PersistenceUnitInfo`, `SmartPersistenceUnitInfo`

public class MutablePersistenceUnitInfo extends Object implements SmartPersistenceUnitInfo
Spring's mutable equivalent of the JPA `PersistenceUnitInfo` interface, used to bootstrap an `EntityManagerFactory` in a container. This is the type exposed to `PersistenceUnitPostProcessor`.

This implementation is largely a JavaBean, offering mutators for all standard `PersistenceUnitInfo` properties.

Since:
  2.0
Author:
  Rod Johnson, Juergen Hoeller, Costin Leau

## Constructor Summary

Constructors
Constructor
Description
`MutablePersistenceUnitInfo()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addJarFileUrl(URL jarFileUrl)`
`void`
`addManagedClassName(String managedClassName)`
Add a managed class name to the persistence provider's metadata.
`void`
`addManagedPackage(String packageName)`
Add a managed package to the persistence provider's metadata.
`void`
`addMappingFileName(String mappingFileName)`
`void`
`addProperty(String name, String value)`
`void`
`addTransformer(ClassTransformer classTransformer)`
This implementation throws an UnsupportedOperationException.
`boolean`
`excludeUnlistedClasses()`
`ClassLoader`
`getClassLoader()`
This implementation returns the default ClassLoader.
`List<URL>`
`getJarFileUrls()`
`DataSource`
`getJtaDataSource()`
`List<String>`
`getManagedClassNames()`
`List<String>`
`getManagedPackages()`
Return a list of managed Java packages, to be introspected by the persistence provider.
`List<String>`
`getMappingFileNames()`
`ClassLoader`
`getNewTempClassLoader()`
This implementation throws an UnsupportedOperationException.
`DataSource`
`getNonJtaDataSource()`
`String`
`getPersistenceProviderClassName()`
`String`
`getPersistenceProviderPackageName()`
`String`
`getPersistenceUnitName()`
`URL`
`getPersistenceUnitRootUrl()`
`String`
`getPersistenceXMLSchemaVersion()`
`Properties`
`getProperties()`
`SharedCacheMode`
`getSharedCacheMode()`
`PersistenceUnitTransactionType`
`getTransactionType()`
`ValidationMode`
`getValidationMode()`
`void`
`setExcludeUnlistedClasses(boolean excludeUnlistedClasses)`
`void`
`setJtaDataSource(DataSource jtaDataSource)`
`void`
`setNonJtaDataSource(DataSource nonJtaDataSource)`
`void`
`setPersistenceProviderClassName(String persistenceProviderClassName)`
`void`
`setPersistenceProviderPackageName(String persistenceProviderPackageName)`
Set the persistence provider's own package name, for exclusion from class transformation.
`void`
`setPersistenceUnitName(String persistenceUnitName)`
`void`
`setPersistenceUnitRootUrl(URL persistenceUnitRootUrl)`
`void`
`setPersistenceXMLSchemaVersion(String persistenceXMLSchemaVersion)`
`void`
`setProperties(Properties properties)`
`void`
`setSharedCacheMode(SharedCacheMode sharedCacheMode)`
`void`
`setTransactionType(PersistenceUnitTransactionType transactionType)`
`void`
`setValidationMode(ValidationMode validationMode)`
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### MutablePersistenceUnitInfo

public MutablePersistenceUnitInfo()

## Method Details

### setPersistenceUnitName

public void setPersistenceUnitName(@Nullable String persistenceUnitName)

### getPersistenceUnitName

@Nullable public String getPersistenceUnitName()

Specified by:
  `getPersistenceUnitName` in interface `PersistenceUnitInfo`

### setPersistenceProviderClassName

public void setPersistenceProviderClassName(@Nullable String persistenceProviderClassName)

### getPersistenceProviderClassName

@Nullable public String getPersistenceProviderClassName()

Specified by:
  `getPersistenceProviderClassName` in interface `PersistenceUnitInfo`

### setTransactionType

public void setTransactionType(PersistenceUnitTransactionType transactionType)

### getTransactionType

public PersistenceUnitTransactionType getTransactionType()

Specified by:
  `getTransactionType` in interface `PersistenceUnitInfo`

### setJtaDataSource

public void setJtaDataSource(@Nullable DataSource jtaDataSource)

### getJtaDataSource

@Nullable public DataSource getJtaDataSource()

Specified by:
  `getJtaDataSource` in interface `PersistenceUnitInfo`

### setNonJtaDataSource

public void setNonJtaDataSource(@Nullable DataSource nonJtaDataSource)

### getNonJtaDataSource

@Nullable public DataSource getNonJtaDataSource()

Specified by:
  `getNonJtaDataSource` in interface `PersistenceUnitInfo`

### addMappingFileName

public void addMappingFileName(String mappingFileName)

### getMappingFileNames

public List<String> getMappingFileNames()

Specified by:
  `getMappingFileNames` in interface `PersistenceUnitInfo`

### addJarFileUrl

public void addJarFileUrl(URL jarFileUrl)

### getJarFileUrls

public List<URL> getJarFileUrls()

Specified by:
  `getJarFileUrls` in interface `PersistenceUnitInfo`

### setPersistenceUnitRootUrl

public void setPersistenceUnitRootUrl(@Nullable URL persistenceUnitRootUrl)

### getPersistenceUnitRootUrl

@Nullable public URL getPersistenceUnitRootUrl()

Specified by:
  `getPersistenceUnitRootUrl` in interface `PersistenceUnitInfo`

### addManagedClassName

public void addManagedClassName(String managedClassName)
Add a managed class name to the persistence provider's metadata.

See Also:
  - `PersistenceUnitInfo.getManagedClassNames()`
  - `addManagedPackage(java.lang.String)`

### getManagedClassNames

public List<String> getManagedClassNames()

Specified by:
  `getManagedClassNames` in interface `PersistenceUnitInfo`

### addManagedPackage

public void addManagedPackage(String packageName)
Add a managed package to the persistence provider's metadata.

Note: This refers to annotated `package-info.java` files. It does not trigger entity scanning in the specified package; this is rather the job of `DefaultPersistenceUnitManager.setPackagesToScan(java.lang.String...)`.

Since:
  4.1
See Also:
  - `SmartPersistenceUnitInfo.getManagedPackages()`
  - `addManagedClassName(java.lang.String)`

### getManagedPackages

public List<String> getManagedPackages()
Description copied from interface: `SmartPersistenceUnitInfo`
Return a list of managed Java packages, to be introspected by the persistence provider. Typically found through scanning but not exposable through `PersistenceUnitInfo.getManagedClassNames()`.

Specified by:
  `getManagedPackages` in interface `SmartPersistenceUnitInfo`
Returns:
  a list of names of managed Java packages (potentially empty)

### setExcludeUnlistedClasses

public void setExcludeUnlistedClasses(boolean excludeUnlistedClasses)

### excludeUnlistedClasses

public boolean excludeUnlistedClasses()

Specified by:
  `excludeUnlistedClasses` in interface `PersistenceUnitInfo`

### setSharedCacheMode

public void setSharedCacheMode(SharedCacheMode sharedCacheMode)

### getSharedCacheMode

public SharedCacheMode getSharedCacheMode()

Specified by:
  `getSharedCacheMode` in interface `PersistenceUnitInfo`

### setValidationMode

public void setValidationMode(ValidationMode validationMode)

### getValidationMode

public ValidationMode getValidationMode()

Specified by:
  `getValidationMode` in interface `PersistenceUnitInfo`

### addProperty

public void addProperty(String name, String value)

### setProperties

public void setProperties(Properties properties)

### getProperties

public Properties getProperties()

Specified by:
  `getProperties` in interface `PersistenceUnitInfo`

### setPersistenceXMLSchemaVersion

public void setPersistenceXMLSchemaVersion(String persistenceXMLSchemaVersion)

### getPersistenceXMLSchemaVersion

public String getPersistenceXMLSchemaVersion()

Specified by:
  `getPersistenceXMLSchemaVersion` in interface `PersistenceUnitInfo`

### setPersistenceProviderPackageName

public void setPersistenceProviderPackageName(@Nullable String persistenceProviderPackageName)
Description copied from interface: `SmartPersistenceUnitInfo`
Set the persistence provider's own package name, for exclusion from class transformation.

Specified by:
  `setPersistenceProviderPackageName` in interface `SmartPersistenceUnitInfo`
See Also:
  - `PersistenceUnitInfo.addTransformer(jakarta.persistence.spi.ClassTransformer)`
  - `PersistenceUnitInfo.getNewTempClassLoader()`

### getPersistenceProviderPackageName

@Nullable public String getPersistenceProviderPackageName()

### getClassLoader

@Nullable public ClassLoader getClassLoader()
This implementation returns the default ClassLoader.

Specified by:
  `getClassLoader` in interface `PersistenceUnitInfo`
See Also:
  - `ClassUtils.getDefaultClassLoader()`

### addTransformer

public void addTransformer(ClassTransformer classTransformer)
This implementation throws an UnsupportedOperationException.

Specified by:
  `addTransformer` in interface `PersistenceUnitInfo`

### getNewTempClassLoader

public ClassLoader getNewTempClassLoader()
This implementation throws an UnsupportedOperationException.

Specified by:
  `getNewTempClassLoader` in interface `PersistenceUnitInfo`

### toString

public String toString()

Overrides:
  `toString` in class `Object`