Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.jpa

public Class EntityManagerSetupImpl

extends Object
implements MetadataRefreshListener
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.sessions.coordination.MetadataRefreshListener
Static Imports
org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION, .PersistenceUnitProperties.NONE, .PersistenceUnitProperties.SCHEMA_GENERATION_CREATE_ACTION, .PersistenceUnitProperties.SCHEMA_GENERATION_CREATE_DATABASE_SCHEMAS, .PersistenceUnitProperties.SCHEMA_GENERATION_CREATE_SCRIPT_SOURCE, .PersistenceUnitProperties.SCHEMA_GENERATION_CREATE_SOURCE, .PersistenceUnitProperties.SCHEMA_GENERATION_DATABASE_ACTION, .PersistenceUnitProperties.SCHEMA_GENERATION_DROP_ACTION, .PersistenceUnitProperties.SCHEMA_GENERATION_DROP_AND_CREATE_ACTION, .PersistenceUnitProperties.SCHEMA_GENERATION_DROP_SCRIPT_SOURCE, .PersistenceUnitProperties.SCHEMA_GENERATION_DROP_SOURCE, .PersistenceUnitProperties.SCHEMA_GENERATION_METADATA_SOURCE, .PersistenceUnitProperties.SCHEMA_GENERATION_METADATA_THEN_SCRIPT_SOURCE, .PersistenceUnitProperties.SCHEMA_GENERATION_NONE_ACTION, .PersistenceUnitProperties.SCHEMA_GENERATION_SCRIPTS_ACTION, .PersistenceUnitProperties.SCHEMA_GENERATION_SCRIPTS_CREATE_TARGET, .PersistenceUnitProperties.SCHEMA_GENERATION_SCRIPTS_DROP_TARGET, .PersistenceUnitProperties.SCHEMA_GENERATION_SCRIPT_SOURCE, .PersistenceUnitProperties.SCHEMA_GENERATION_SCRIPT_THEN_METADATA_SOURCE, .PersistenceUnitProperties.SCHEMA_GENERATION_SQL_LOAD_SCRIPT_SOURCE, org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.generateDefaultTables, .EntityManagerFactoryProvider.getConfigProperty, .EntityManagerFactoryProvider.getConfigPropertyAsString, .EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug, .EntityManagerFactoryProvider.getConfigPropertyLogDebug, .EntityManagerFactoryProvider.hasConfigProperty, .EntityManagerFactoryProvider.login, .EntityManagerFactoryProvider.mergeMaps, .EntityManagerFactoryProvider.translateOldProperties, .EntityManagerFactoryProvider.warnOldProperties

INTERNAL: This class handles deployment of a persistence unit. In predeploy the meta-data is processed and weaver transformer is returned to allow weaving of the persistent classes. In deploy the project and session are initialize and registered.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum

Field Summary

Modifier and TypeField and Description
protected EntityManagerSetupImpl
protected Set<EntityManagerSetupImpl>
public static String[]
protected ConcurrencyManager
protected Boolean
public static final String
ERROR_LOADING_XML_FILE

Initial -----------> PredeployFailed --- | | V | Predeployed ---> DeployFailed -- | | | | V V V HalfDeployed --> Deployed -> Undeployed | ^ V | DeployFailed -------------------

public static final String
protected int
protected boolean
protected boolean
isMetadataExpired

Used to indicate that an EntityManagerFactoryImpl based on this EntityManagerSetupImpl has been refreshed.

protected boolean
protected boolean
private Metamodel
metaModel

Reference to the Metamodel for this deployment and session.

pack-priv PersistenceUnitProcessor.Mode
protected PersistenceException
protected PersistenceUnitInfo
protected String
private MetadataProcessor
protected ProjectCache
protected boolean
protected SecurableObjectHolder
protected AbstractSession
protected String
protected boolean
protected String
state

Initial -----> HalfPredeployedCompositeMember -----> PredeployFailed | ^ | V------->| V Predeployed

public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
protected StaticWeaveInfo
protected List<StructConverter>
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
private PersistenceWeaver
weaver

Holds a reference to the weaver class transformer so it can be cleared after login.

pack-priv boolean

Constructor Summary

AccessConstructor and Description
public
EntityManagerSetupImpl(String persistenceUnitUniqueName, String sessionName)

public

Method Summary

Modifier and TypeMethod and Description
private void
addBeanValidationListeners(Map<K, V>
merged properties for this persistence unit
puProperties
,
ClassLoader appClassLoader)

If Bean Validation is enabled, bootstraps Bean Validation on descriptors.

protected static String
addFileSeperator(String appLocation)

protected void
addProjectToSession(ServerSession session, Project project)

Adds descriptors plus sequencing info found on the project to the session.

protected void
addSessionToGlobalSessionManager()

Put the given session into the session manager so it can be looked up later

public void
addStructConverters()

Add the StructConverters that were specified by annotation on the DatabasePlatform This method must be called after the DatabasePlatform has been detected

private static String
assertCompatiblePersistenceUnitName(String persistenceUnitUniqueName)

protected void
assignCMP3Policy()

Assign a CMP3Policy to each descriptor, and sets the OptimisticLockingPolicy's LockOnChangeMode if applicable.

protected static Object
buildObjectForClass(Class<?> clazz, Class<?> mustBeImplementedInterface)

This method will be used to validate the specified class and return it's instance.

protected static String
public void
changeSessionName(String newSessionName)

protected PersistenceException
protected PersistenceException
public AbstractSession

Returns:

An EntityManagerFactory to be used by the Container to obtain EntityManagers
deploy
(ClassLoader
The class loader that was used to load the entity classes. This loader will be maintained for the lifespan of the loaded classes.
realClassLoader
,
Map<K, V>
added to persistence unit properties for updateServerSession overriding existing properties. In JSE case it allows to alter properties in main (as opposed to preMain where preDeploy is called).
additionalProperties
)

Deploy a persistence session and return an EntityManagerFactory.

protected void
deployCompositeMembers(Map<K, V> deployProperties, ClassLoader realClassLoader)

protected static Class<?>
findClass(String className, ClassLoader loader)

protected static <T> Class<T>
findClassForProperty(String className, String propertyName, ClassLoader loader)

private static <T> Class<T>
findClassForPropertyInternal(String clsName, String propName, ClassLoader... loaders)

private void
finishProcessingDescriptorEvents(ClassLoader realClassLoader)

INTERNAL: This method is used to resolve Descriptor Events processed earlier into EventHolders that now need to be used to create the DescriptorEventListeners and added to the DescriptorEventManager

public EntityManagerSetupImpl
protected static Map<String, SEPersistenceUnitInfo>
getCompositeMemberPuInfoMap(PersistenceUnitInfo puInfo, Map<K, V> predeployProperties)

protected static Set<SEPersistenceUnitInfo>
getCompositeMemberPuInfoSet(PersistenceUnitInfo puInfo, Map<K, V> predeployProperties)

public static ConnectionPolicy.ExclusiveMode
getConnectionPolicyExclusiveModeFromProperties(Map<K, V> m, AbstractSession abstractSession, boolean useSystemAsDefault)

public DatabaseSessionImpl
public DatabaseSessionImpl
getDatabaseSession(Map<K, V> props)

We may be provided a connection via the properties to use.

protected DataSource
getDatasourceFromProperties(Map<K, V> m, String property, DataSource defaultDataSource)

This is used to return either the defaultDatasource or, if one exists, a datasource defined under the property from the Map m.

public String
getDeployedSessionName()

Return the name of the session this SetupImpl is building.

public int
public Metamodel

Returns:

Metamodel instance
getMetamodel
(ClassLoader classLoader)

INTERNAL: Return an instance of Metamodel interface for access to the metamodel of the persistence unit.

public static String
getOrBuildSessionName(Map<K, V> properties, PersistenceUnitInfo puInfo, String persistenceUnitUniqueName)

public PersistenceUnitInfo
public String
public AbstractSession
public String
protected List<StructConverter>
getStructConverters(ClassLoader realClassLoader)

Internal: Returns a list of StructConverter instances from a list of StructConverter names stored within the project.

private static ValidationMode

Returns:

validation mode
getValidationMode
(PersistenceUnitInfo
PersitenceUnitInfo instance for this persistence unit
persitenceUnitInfo
,
Map<K, V>
merged properties for this persistence unit
puProperties
)

Validation mode from information in persistence.xml and properties specified at EMF creation

protected boolean
protected boolean
protected void
initializeCanonicalMetamodel(Metamodel model)

INTERNAL: Initialize the Canonical Metamodel classes generated by EclipseLink

protected void
protected void
initSession()

Normally when a property is missing nothing should be applied to the session.

public boolean
public static boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
isMetadataExpired()

Used to indicate that an EntityManagerFactoryImpl based on this EntityManagerSetupImpl has been refreshed.

public boolean
public boolean
public boolean
public boolean
protected boolean
isValidationOnly(Map<K, V> m, boolean shouldMergeMap)

protected Map<K, V>
public boolean
public static boolean
protected static void
overrideMemberProperties(Map<K, V> memberProperties, Map<K, V> compositeProperties)

public synchronized ClassTransformer

Returns:

A transformer (which may be null) that should be plugged into the proper classloader to allow classes to be transformed as they get loaded.
predeploy
(PersistenceUnitInfo info, Map<K, V> extendedProperties)

Perform any steps necessary prior to actual deployment.

protected void
predeployCompositeMembers(Map<K, V> predeployProperties, ClassLoader tempClassLoader)

public void
preInitializeCanonicalMetamodel(EntityManagerFactoryImpl factory)

INTERNAL: First phase of canonical metamodel initialization.

public void
preInitializeMetamodel()

INTERNAL: Cause the first phase of metamodel initialization.

protected void
private void
processDescriptorsFromCachedProject(ClassLoader realClassLoader)

INTERNAL: This method is used to resolve Descriptor Customizers that might have been stored in the project for JPA project caching.

protected void
public EntityManagerSetupImpl
refreshMetadata(Map<K, V> properties)

Create a new version of this EntityManagerSetupImpl and cache it.

protected void
removeSessionFromGlobalSessionManager()

This method can be used to ensure the session represented by emSetupImpl is removed from the SessionManager.

public void
protected void
setDescriptorNamedQueries(Map<K, V> m)

Copy named queries defined in EclipseLink descriptor into the session if it was indicated to do so.

protected void
setExceptionHandler(Map<K, V> m, ClassLoader loader)

Allow customized exception handler to be added into session.

public void
setIsInContainerMode(boolean isInContainerMode)

This sets the isInContainerMode flag.

public void
setIsMetadataExpired(boolean hasExpiredMetadata)

Used to indicate that an EntityManagerFactoryImpl based on this EntityManagerSetupImpl has been refreshed.

public void
setMetamodel(Metamodel aMetamodel)

INTERNAL: Convenience function to allow us to reset the Metamodel in the possible case that we want to regenerate it.

public void
setRequiresConnection(boolean requiresConnection)

INTERNAL: By default we require a connection to the database.

protected void
setSessionEventListener(Map<K, V> m, ClassLoader loader)

Allow customized session event listener to be added into session.

public void
public boolean
shouldGetSessionOnCreateFactory(Map<K, V> m)

Return if the session should be deployed and connected during the creation of the EntityManagerFactory, or if it should be deferred until createEntityManager().

public boolean
public boolean
shouldSendMetadataRefreshCommand(Map<K, V> m)

Return if MetadataSource refresh commands should be sent when refresh is called Checks the PersistenceUnitProperties.METADATA_SOURCE_RCM_COMMAND property and defaults to true.

private static String
public static void
public void
triggerMetadataRefresh(Map<K, V> properties)

Implements org.eclipse.persistence.sessions.coordination.MetadataRefreshListener.triggerMetadataRefresh.

This method is just a wrapper on refreshMetadata so that core does not need a dependency on JPA due to the EntityManagerSetupImpl return value.
public synchronized void
undeploy()

Undeploy may be called several times, but only the call that decreases factoryCount to 0 disconnects the session and removes it from the session manager.

protected void
updateAllowExtendedCacheLogging(Map<K, V> m)

Enable or disable extended logging of JPA L2 cache usage.

protected void
updateAllowExtendedThreadLogging(Map<K, V> m)

Enable or disable extended thread logging.

protected void
updateAllowExtendedThreadLoggingThreadDump(Map<K, V> m)

Enable or disable thread dump addition to extended thread logging.

protected void
updateAllowNativeSQLQueriesSetting(Map<K, V> m)

Enable or disable the capability of Native SQL function.

protected void
updateAllowQueryResultsCacheValidation(Map<K, V> m)

Enable or disable query result cache validation.

protected void
updateAllowZeroIdSetting(Map<K, V> m)

Enable or disable default allowing 0 as an id.

protected void
updateBatchWritingSetting(Map<K, V> persistenceProperties, ClassLoader loader)

Update batch writing setting.

protected void
updateCacheCoordination(Map<K, V> m, ClassLoader loader)

Configure cache coordination using properties.

protected void
updateCacheStatementSettings(Map<K, V> m)

Enable or disable statements cached, update statements cache size.

public static void
updateCaseSensitivitySettings(Map<K, V> m, MetadataProject project, AbstractSession session)

/** Enable or disable forcing field names to be case insensitive.

protected void
updateCompositeMembersProperties(Map<K, V> compositeProperties)

protected void
updateCompositeMembersProperties(Set<SEPersistenceUnitInfo> compositePuInfos, Map<K, V> compositeProperties)

private void
private void
private void
private void
private void
private void
private void
updateConcurrencyManagerMaxAllowedSleepTime(Map<K, V> persistenceProperties)

private void
private void
private void
private void
private void
updateConcurrencyManagerWaitTime(Map<K, V> persistenceProperties)

private void
updateConcurrencySemaphoreLogTimeout(Map<K, V> persistenceProperties)

private void
updateConcurrencySemaphoreMaxTimePermit(Map<K, V> persistenceProperties)

protected void
updateConnectionPolicy(ServerSession serverSession, Map<K, V> m)

protected void
updateConnectionSettings(ServerSession serverSession, Map<K, V> properties)

Process all properties under "eclipselink.connection-pool.".

protected void
updateDatabaseEventListener(Map<K, V> m, ClassLoader loader)

Checks for database events listener properties.

protected void
protected void
updateFreeMemory(Map<K, V> m)

Allow the deployment metadata to be freed post-deploy to conserve memory.

protected void
updateIdValidation(Map<K, V> m)

Enable or disable default allowing 0 as an id.

protected void
updateIndexForeignKeys(Map<K, V> m)

Sets shouldCreateIndicesOnForeignKeys DDL generation option.

protected void
updateJPQLParser(Map<K, V> m)

Enable or disable the capability of Native SQL function.

private static void
updateJTAControllerInPlatform(final ServerPlatform
target ServerPlatform instance
serverPlatform
,
final String
JTA transaction controller class name
jtaControllerClassName
,
final ClassLoader
class loader containing JTA transaction controller class
loader
)

Update JTA transaction controller class of provided ServerPlatform instance.

private void
updateLockingTimestampDefault(Map<K, V> persistenceProperties)

protected void
updateLoggers(Map<K, V>
the properties map
persistenceProperties
,
boolean
the boolean that denotes a serverPlatform change in the session.
serverPlatformChanged
,
ClassLoader loader)

Update loggers and settings for the singleton logger and the session logger.

protected void
updateLoginDefaultConnector(DatasourceLogin login, Map<K, V> m)

In cases where there is no data source, we will use properties to configure the login for our session.

protected void
updateLogins(Map<K, V> m)

Override the default login creation method.

protected void
updateMetadataRepository(Map<K, V> m, ClassLoader loader)

Load the Metadata Repository for Extensibility

private void
updateNamingIntoIndexed(Map<K, V> persistenceProperties)

protected void
updateNativeSQLSetting(Map<K, V> m)

Enable or disable the capability of Native SQL function.

protected void
updatePartitioning(Map<K, V> m, ClassLoader loader)

Checks for partitioning properties.

protected void
updatePessimisticLockTimeout(Map<K, V>
the properties map
persistenceProperties
)

Update the default pessimistic lock timeout value.

protected void
updatePessimisticLockTimeoutUnit(Map<K, V>
the properties map
persistenceProperties
)

Update the default pessimistic lock timeout unit value.

protected void
updatePools(ServerSession serverSession, Map<K, V> m)

Configure the internal connection pooling parameters.

protected void
updateProfiler(Map<K, V> persistenceProperties, ClassLoader loader)

Check for the PROFILER persistence or system property and set the Session's profiler.

protected void
updateProjectCache(Map<K, V> m, ClassLoader loader)

Load the projectCacheAccessor for JPA project caching

private void
updateQueryTimeout(Map<K, V> persistenceProperties)

private void
updateQueryTimeoutUnit(Map<K, V> persistenceProperties)

protected void
updateRemote(Map<K, V> m, ClassLoader loader)

Checks for partitioning properties.

protected void
updateSequencing(Map<K, V> m)

Configure sequencing settings.

protected void
protected void
updateSerializer(Map<K, V> m, ClassLoader loader)

Update session serializer.

protected boolean

Returns:

true if the ServerPlatform has changed.
updateServerPlatform
(Map<K, V> m, ClassLoader loader)

Updates the EclipseLink ServerPlatform class for use with this platform.

protected void
updateSession(Map<K, V> m, ClassLoader loader)

Make any changes to our ServerSession that can be made after it is created.

protected void
updateSharedCacheMode(Map<K, V> m)

Sets the SharedCacheMode with values from the jakarta.persistence.sharedCache.mode property.

protected void
updateShouldOptimizeResultSetAccess(Map<K, V> m)

Update whether session ShouldOptimizeResultSetAccess.

private void
updateSQLCallDeferralDefault(Map<K, V> persistenceProperties)

protected void
updateSQLCastSetting(Map<K, V> m)

Enable or disable SQL casting.

protected void
updateTableCreationSettings(Map<K, V> m)

sets the TABLE_CREATION_SUFFIX property on the session's project to be applied to all table creation statements (DDL)

protected void
updateTemporalMutableSetting(Map<K, V> m)

Enable or disable default temporal mutable setting.

protected void
updateTenancy(Map<K, V> m, ClassLoader loader)

Update whether session should use externally defined multi tenancy.

protected void
updateTolerateInvalidJPQL(Map<K, V> m)

Update whether session should tolerate invalid JPQL at creation time.

protected void
updateTunerDeploy(Map<K, V> m, ClassLoader loader)

Check for a tuning property and run the tuner deploy.

protected void
updateTunerPostDeploy(Map<K, V> m, ClassLoader loader)

Check for a tuning property and run the tuner deploy.

protected void
updateTunerPreDeploy(Map<K, V> m, ClassLoader loader)

Check for a tuning property and run the tuner preDeploy.

protected void
updateUppercaseSetting(Map<K, V> m)

Enable or disable forcing field names to uppercase.

public void
writeDDL(Map<K, V> props, DatabaseSessionImpl session, ClassLoader classLoader)

INTERNAL: Generate the DDL per the properties specified.

protected void
writeDDL(String ddlGeneration, Map<K, V> props, DatabaseSessionImpl session, ClassLoader classLoader)

INTERNAL: Generate the DDL from the persistence unit metadata.

protected void
writeDDL(String generationSourceProperty, String scriptGenerationSourceProperty, EntityManagerSetupImpl.TableCreationType tableCreationType, Map<K, V> props, DatabaseSessionImpl session, ClassLoader loader)

INTERNAL: Generate the DDL per the properties given.

protected void
writeDDLToDatabase(SchemaManager mgr, EntityManagerSetupImpl.TableCreationType ddlType)

INTERNAL: Generate and write DDL from the persistence unit metadata to the database.

protected void
protected void
writeDDLToFiles(SchemaManager mgr, String appLocation, Object createDDLJdbc, Object dropDDLJdbc, EntityManagerSetupImpl.TableCreationType ddlType, Map<K, V> props)

Write the DDL to the files provided.

protected void
writeMetadataDDLToDatabase(EntityManagerSetupImpl.TableCreationType tableCreationType, Map<K, V> props, DatabaseSessionImpl session, ClassLoader classLoader)

INTERNAL: Generate and write DDL from the persistence unit metadata to the database.

protected void
writeMetadataDDLToScript(EntityManagerSetupImpl.TableCreationType tableCreationType, Map<K, V> props, DatabaseSessionImpl session, ClassLoader classLoader)

INTERNAL: Generate and write DDL from the persistence unit metadata to scripts.

protected void
writeSourceScriptToDatabase(Object source, DatabaseSessionImpl session, ClassLoader loader)

This method will read SQL from a reader or URL and send it through to the database.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait