Top Description Fields Constructors Methods
org.springframework.orm.jpa.persistenceunit

public Class MutablePersistenceUnitInfo

extends Object
implements SmartPersistenceUnitInfo
Class Inheritance
All Implemented Interfaces
org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo, jakarta.persistence.spi.PersistenceUnitInfo
Known Direct Subclasses
org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo
Imports
java.net.URL, java.util.ArrayList, .List, .Properties, javax.sql.DataSource, jakarta.persistence.SharedCacheMode, .ValidationMode, jakarta.persistence.spi.ClassTransformer, .PersistenceUnitTransactionType, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils

Spring's base implementation of the JPA jakarta.persistence.spi.PersistenceUnitInfo interface, used to bootstrap an EntityManagerFactory in a container.

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

Authors
Rod Johnson, Juergen Hoeller, Costin Leau
Since
2.0

Field Summary

Modifier and TypeField and Description
private boolean
private final List<URL>
private DataSource
private final List<String>
private final List<String>
private final List<String>
private DataSource
private String
private String
private String
private URL
private String
private Properties
private SharedCacheMode
private PersistenceUnitTransactionType
private ValidationMode

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addJarFileUrl(URL jarFileUrl)

public void
addManagedClassName(String managedClassName)

Add a managed class name to the persistence provider's metadata.

public void
addManagedPackage(String packageName)

Add a managed package to the persistence provider's metadata.

public void
addMappingFileName(String mappingFileName)

public void
addProperty(String name, String value)

public void
addTransformer(ClassTransformer
provider-supplied transformer that the container invokes at class-(re)definition time
classTransformer
)

Implements jakarta.persistence.spi.PersistenceUnitInfo.addTransformer.

This implementation throws an UnsupportedOperationException.
public boolean
excludeUnlistedClasses()

Implements jakarta.persistence.spi.PersistenceUnitInfo.excludeUnlistedClasses.

Returns whether classes in the root of the persistence unit that have not been explicitly listed are to be included in the set of managed classes.
public ClassLoader
getClassLoader()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getClassLoader.

This implementation returns the default ClassLoader.
public List<URL>
getJarFileUrls()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getJarFileUrls.

Returns a list of URLs for the jar files or exploded jar file directories that the persistence provider must examine for managed classes of the persistence unit.
public DataSource
getJtaDataSource()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getJtaDataSource.

Returns the JTA-enabled data source to be used by the persistence provider.
public List<String>
getManagedClassNames()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getManagedClassNames.

Returns the list of the names of the classes that the persistence provider must add to its set of managed classes.
public List<String>
getManagedPackages()

Implements org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo.getManagedPackages.

Return a list of managed Java packages, to be introspected by the persistence provider.
public List<String>
getMappingFileNames()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getMappingFileNames.

Returns the list of the names of the mapping files that the persistence provider must load to determine the mappings for the entity classes.
public ClassLoader
getNewTempClassLoader()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getNewTempClassLoader.

This implementation throws an UnsupportedOperationException.
public DataSource
getNonJtaDataSource()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getNonJtaDataSource.

Returns the non-JTA-enabled data source to be used by the persistence provider for accessing data outside a JTA transaction.
public String
getPersistenceProviderClassName()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceProviderClassName.

Returns the fully qualified name of the persistence provider implementation class.
public String
public String
public URL
getPersistenceUnitRootUrl()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceUnitRootUrl.

Returns the URL for the jar file or directory that is the root of the persistence unit.
public String
getPersistenceXMLSchemaVersion()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceXMLSchemaVersion.

Returns the schema version of the persistence.xml file.
public Properties
public SharedCacheMode
getSharedCacheMode()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getSharedCacheMode.

Returns the specification of how the provider must use a second-level cache for the persistence unit.
public PersistenceUnitTransactionType
getTransactionType()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getTransactionType.

Returns the transaction type of the entity managers created by the EntityManagerFactory.
public ValidationMode
getValidationMode()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getValidationMode.

Returns the validation mode to be used by the persistence provider for the persistence unit.
public void
setExcludeUnlistedClasses(boolean excludeUnlistedClasses)

public void
public void
setNonJtaDataSource(DataSource nonJtaDataSource)

public void
setPersistenceProviderClassName(String persistenceProviderClassName)

public void
setPersistenceProviderPackageName(String persistenceProviderPackageName)

Implements org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo.setPersistenceProviderPackageName.

Set the persistence provider's own package name, for exclusion from class transformation.
public void
setPersistenceUnitName(String persistenceUnitName)

public void
setPersistenceUnitRootUrl(URL persistenceUnitRootUrl)

public void
setPersistenceXMLSchemaVersion(String persistenceXMLSchemaVersion)

public void
public void
public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

excludeUnlistedClassesback to summary
private boolean excludeUnlistedClasses
jarFileUrlsback to summary
private final List<URL> jarFileUrls
jtaDataSourceback to summary
private DataSource jtaDataSource
Annotations
@Nullable
managedClassNamesback to summary
private final List<String> managedClassNames
managedPackagesback to summary
private final List<String> managedPackages
mappingFileNamesback to summary
private final List<String> mappingFileNames
nonJtaDataSourceback to summary
private DataSource nonJtaDataSource
Annotations
@Nullable
persistenceProviderClassNameback to summary
private String persistenceProviderClassName
Annotations
@Nullable
persistenceProviderPackageNameback to summary
private String persistenceProviderPackageName
Annotations
@Nullable
persistenceUnitNameback to summary
private String persistenceUnitName
Annotations
@Nullable
persistenceUnitRootUrlback to summary
private URL persistenceUnitRootUrl
Annotations
@Nullable
persistenceXMLSchemaVersionback to summary
private String persistenceXMLSchemaVersion
propertiesback to summary
private Properties properties
sharedCacheModeback to summary
private SharedCacheMode sharedCacheMode
transactionTypeback to summary
private PersistenceUnitTransactionType transactionType
Annotations
@Nullable
validationModeback to summary
private ValidationMode validationMode

Constructor Detail

MutablePersistenceUnitInfoback to summary
public MutablePersistenceUnitInfo()

Method Detail

addJarFileUrlback to summary
public void addJarFileUrl(URL jarFileUrl)
addManagedClassNameback to summary
public void addManagedClassName(String managedClassName)

Add a managed class name to the persistence provider's metadata.

See Also
jakarta.persistence.spi.PersistenceUnitInfo#getManagedClassNames(), addManagedPackage
addManagedPackageback to summary
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.

Since
4.1
See Also
SmartPersistenceUnitInfo#getManagedPackages(), addManagedClassName
addMappingFileNameback to summary
public void addMappingFileName(String mappingFileName)
addPropertyback to summary
public void addProperty(String name, String value)
addTransformerback to summary
public void addTransformer(ClassTransformer classTransformer)

Implements jakarta.persistence.spi.PersistenceUnitInfo.addTransformer.

This implementation throws an UnsupportedOperationException.

Parameters
classTransformer:ClassTransformer

Doc from jakarta.persistence.spi.PersistenceUnitInfo.addTransformer.

provider-supplied transformer that the container invokes at class-(re)definition time

Annotations
@Override
excludeUnlistedClassesback to summary
public boolean excludeUnlistedClasses()

Implements jakarta.persistence.spi.PersistenceUnitInfo.excludeUnlistedClasses.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.excludeUnlistedClasses.

Returns whether classes in the root of the persistence unit that have not been explicitly listed are to be included in the set of managed classes. This value corresponds to the exclude-unlisted-classes element in the persistence.xml file.

Returns:boolean

whether classes in the root of the persistence unit that have not been explicitly listed are to be included in the set of managed classes

Annotations
@Override
getClassLoaderback to summary
public ClassLoader getClassLoader()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getClassLoader.

This implementation returns the default ClassLoader.

Returns:ClassLoader

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getClassLoader.

ClassLoader that the provider may use to load any classes, resources, or open URLs

Annotations
@Override
@Nullable
See Also
org.springframework.util.ClassUtils#getDefaultClassLoader()
getJarFileUrlsback to summary
public List<URL> getJarFileUrls()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getJarFileUrls.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getJarFileUrls.

Returns a list of URLs for the jar files or exploded jar file directories that the persistence provider must examine for managed classes of the persistence unit. Each URL corresponds to a jar-file element in the persistence.xml file. A URL will either be a file: URL referring to a jar file or referring to a directory that contains an exploded jar file, or some other URL from which an InputStream in jar format can be obtained.

Returns:List<URL>

a list of URL objects referring to jar files or directories

Annotations
@Override
getJtaDataSourceback to summary
public DataSource getJtaDataSource()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getJtaDataSource.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getJtaDataSource.

Returns the JTA-enabled data source to be used by the persistence provider. The data source corresponds to the jta-data-source element in the persistence.xml file or is provided at deployment or by the container.

Returns:DataSource

the JTA-enabled data source to be used by the persistence provider

Annotations
@Override
@Nullable
getManagedClassNamesback to summary
public List<String> getManagedClassNames()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getManagedClassNames.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getManagedClassNames.

Returns the list of the names of the classes that the persistence provider must add to its set of managed classes. Each name corresponds to a named class element in the persistence.xml file.

Returns:List<String>

the list of the names of the classes that the persistence provider must add to its set of managed classes

Annotations
@Override
getManagedPackagesback to summary
public List<String> getManagedPackages()

Implements org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo.getManagedPackages.

Doc from org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo.getManagedPackages.

Return a list of managed Java packages, to be introspected by the persistence provider. Typically found through scanning but not exposable through getManagedClassNames().

Returns:List<String>

a list of names of managed Java packages (potentially empty)

Annotations
@Override
getMappingFileNamesback to summary
public List<String> getMappingFileNames()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getMappingFileNames.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getMappingFileNames.

Returns the list of the names of the mapping files that the persistence provider must load to determine the mappings for the entity classes. The mapping files must be in the standard XML mapping format, be uniquely named and be resource-loadable from the application classpath. Each mapping file name corresponds to a mapping-file element in the persistence.xml file.

Returns:List<String>

the list of mapping file names that the persistence provider must load to determine the mappings for the entity classes

Annotations
@Override
getNewTempClassLoaderback to summary
public ClassLoader getNewTempClassLoader()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getNewTempClassLoader.

This implementation throws an UnsupportedOperationException.

Returns:ClassLoader

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getNewTempClassLoader.

temporary ClassLoader with same visibility as current loader

Annotations
@Override
getNonJtaDataSourceback to summary
public DataSource getNonJtaDataSource()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getNonJtaDataSource.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getNonJtaDataSource.

Returns the non-JTA-enabled data source to be used by the persistence provider for accessing data outside a JTA transaction. The data source corresponds to the named non-jta-data-source element in the persistence.xml file or provided at deployment or by the container.

Returns:DataSource

the non-JTA-enabled data source to be used by the persistence provider for accessing data outside a JTA transaction

Annotations
@Override
@Nullable
getPersistenceProviderClassNameback to summary
public String getPersistenceProviderClassName()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceProviderClassName.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceProviderClassName.

Returns the fully qualified name of the persistence provider implementation class. Corresponds to the provider element in the persistence.xml file.

Returns:String

the fully qualified name of the persistence provider implementation class

Annotations
@Override
@Nullable
getPersistenceProviderPackageNameback to summary
public String getPersistenceProviderPackageName()
Annotations
@Nullable
getPersistenceUnitNameback to summary
public String getPersistenceUnitName()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceUnitName.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceUnitName.

Returns the name of the persistence unit. Corresponds to the name attribute in the persistence.xml file.

Returns:String

the name of the persistence unit

Annotations
@Override
@Nullable
getPersistenceUnitRootUrlback to summary
public URL getPersistenceUnitRootUrl()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceUnitRootUrl.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceUnitRootUrl.

Returns the URL for the jar file or directory that is the root of the persistence unit. (If the persistence unit is rooted in the WEB-INF/classes directory, this will be the URL of that directory.) The URL will either be a file: URL referring to a jar file or referring to a directory that contains an exploded jar file, or some other URL from which an InputStream in jar format can be obtained.

Returns:URL

a URL referring to a jar file or directory

Annotations
@Override
@Nullable
getPersistenceXMLSchemaVersionback to summary
public String getPersistenceXMLSchemaVersion()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceXMLSchemaVersion.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getPersistenceXMLSchemaVersion.

Returns the schema version of the persistence.xml file.

Returns:String

persistence.xml schema version

Annotations
@Override
getPropertiesback to summary
public Properties getProperties()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getProperties.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getProperties.

Returns a properties object. Each property corresponds to a property element in the persistence.xml file or to a property set by the container.

Returns:Properties

Properties object

Annotations
@Override
getSharedCacheModeback to summary
public SharedCacheMode getSharedCacheMode()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getSharedCacheMode.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getSharedCacheMode.

Returns the specification of how the provider must use a second-level cache for the persistence unit. The result of this method corresponds to the shared-cache-mode element in the persistence.xml file.

Returns:SharedCacheMode

the second-level cache mode that must be used by the provider for the persistence unit

Annotations
@Override
getTransactionTypeback to summary
public PersistenceUnitTransactionType getTransactionType()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getTransactionType.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getTransactionType.

Returns the transaction type of the entity managers created by the EntityManagerFactory. The transaction type corresponds to the transaction-type attribute in the persistence.xml file.

Returns:PersistenceUnitTransactionType

transaction type of the entity managers created by the EntityManagerFactory

Annotations
@Override
getValidationModeback to summary
public ValidationMode getValidationMode()

Implements jakarta.persistence.spi.PersistenceUnitInfo.getValidationMode.

Doc from jakarta.persistence.spi.PersistenceUnitInfo.getValidationMode.

Returns the validation mode to be used by the persistence provider for the persistence unit. The validation mode corresponds to the validation-mode element in the persistence.xml file.

Returns:ValidationMode

the validation mode to be used by the persistence provider for the persistence unit

Annotations
@Override
setExcludeUnlistedClassesback to summary
public void setExcludeUnlistedClasses(boolean excludeUnlistedClasses)
setJtaDataSourceback to summary
public void setJtaDataSource(DataSource jtaDataSource)
setNonJtaDataSourceback to summary
public void setNonJtaDataSource(DataSource nonJtaDataSource)
setPersistenceProviderClassNameback to summary
public void setPersistenceProviderClassName(String persistenceProviderClassName)
setPersistenceProviderPackageNameback to summary
public void setPersistenceProviderPackageName(String persistenceProviderPackageName)

Implements org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo.setPersistenceProviderPackageName.

Doc from org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo.setPersistenceProviderPackageName.

Set the persistence provider's own package name, for exclusion from class transformation.

Annotations
@Override
setPersistenceUnitNameback to summary
public void setPersistenceUnitName(String persistenceUnitName)
setPersistenceUnitRootUrlback to summary
public void setPersistenceUnitRootUrl(URL persistenceUnitRootUrl)
setPersistenceXMLSchemaVersionback to summary
public void setPersistenceXMLSchemaVersion(String persistenceXMLSchemaVersion)
setPropertiesback to summary
public void setProperties(Properties properties)
setSharedCacheModeback to summary
public void setSharedCacheMode(SharedCacheMode sharedCacheMode)
setTransactionTypeback to summary
public void setTransactionType(PersistenceUnitTransactionType transactionType)
setValidationModeback to summary
public void setValidationMode(ValidationMode validationMode)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override