Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Configuring a Session (ELUG)
For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/
Contents
- 1 Configuring Common Session Options
- 2 Configuring a Primary Mapping Project
- 3 Configuring a Session Login
- 4 Configuring Logging
- 5 Configuring Multiple Mapping Projects
- 6 Configuring a Performance Profiler
- 7 Configuring an Exception Handler
- 8 Configuring a Session Customizer Class
- 9 Configuring the Server Platform
- 10 Configuring Session Event Listeners
- 11 Configuring the Integrity Checker
- 12 Configuring Connection Policy
- 13 Configuring Named Queries at the Session Level
This table lists the types of EclipseLink sessions that you can configure and provides a cross-reference to the type-specific chapter that lists the configurable options supported by that type.
If you are creating... | See... |
---|---|
Configuring Exclusive Isolated Client Sessions for Virtual Private Database | |
For more information, see the following:
Configuring Common Session Options
This table lists the configurable options shared by two or more EclipseLink session types. In addition to the configurable options described here, you must also configure the options described for the specific Session Types, as shown in The Configuring EclipseLink Sessions table.
Option to Configure | EclipseLink Workbench | Java |
---|---|---|
Configuring a Primary Mapping Project
The mapping project contains your EclipseLink mapping metadata (see Introduction to Projects), including descriptors and mappings. Each session is associated with at least one project so that the session can register the descriptors.
This table summarizes which sessions support a primary mapping project configuration.
Session | Using the Workbench |
Using Java |
---|---|---|
Using the Workbench, you can export your mapping metadata as either a deployment XML file or as a Java class. Consequently, in a session, you can specify the mapping project as an XML file or as a Java class.
If you export your mapping metadata as a Java class, you must compile it and add it to the session configuration classpath before adding it to a session.
Note: When specifying the mapping project using XML, you can specify the Java resource path. In most applications, the sessions.xml and project.xml files are deployed inside the JAR file, and the project XML path is specified as a Java resource path. When specifying the Java resource path, ensure that you are using the forward slash character ( / ) for directories, not the back slash ( \ ). For example, com/myapp/mypersistence/my-project.xml, or META-INF/my-project.xml. |
See Configuring Multiple Mapping Projects for information on configuring additional EclipseLink projects for the session.
How to Configure a Primary Mapping Project Using Workbench
To specify the primary EclipseLink project metadata for your session, use this procedure:
- Select a server or database session in the Navigator. Its properties appear in the Editor.
- Click the General tab. The General tab appears.
- Click the Project subtab. The Project subtab appears.
General Tab, Project Subtab, Primary Project Option - Select the following options:
- Click Edit to define the primary project. The Edit PrimaryProject dialog box appears.
- Use the Multiple Projects option to add additional projects to the session.
Edit Primary Project Dialog Box
Edit Primary Project Dialog Box
- Complete each field on the Edit Primary Project dialog box.
Use this information to enter date in each field of the Edit Primary Project dialog box:
Field | Description |
---|---|
XML | Select XML to add a mapping project as a deployment XML file. Click Browse to select the file. |
Class | Select Class to add a mapping project as a compiled Java class file. Click Browse to select the file. |
How to Configure a Primary Mapping Project Using Java
Using Java, you can register descriptors with a session using the following API:
- Project API – Read your project.xml file (or instantiate your project class) and create your session using Project method createServerSession or createDatabaseSession.
- Session API – Add a descriptor or set of descriptors to a session using the DatabaseSession API that the following table lists. Descriptors should be registered before login, but independent sets of descriptors can be added after login.
DatabaseSession API for Registering Descriptors
Session Method | Description |
---|---|
addDescriptors(Project) |
Add to the session all the descriptors owned by the passed in Project. |
addDescriptors(Vector) |
Add to the session all the descriptors in the passed in Vector. |
addDescriptor(Descriptor) |
Add an individual descriptor to the session. |
Configuring a Session Login
A session login encapsulates details of data source access for any session that persists to a data source. The session login overrides any other login configuration.
This table summarizes which sessions support session login configuration.
Session | Session Login |
---|---|
The session login provides access to a variety of features, including the following:
- Connection configuration such as whether or not to use external connection pooling.
- Sequencing configuration (that overrides sequencing configuration made at the project level, if any).
- Miscellaneous options specific to your chosen data source.
- Properties (arbitrary, application-specific named values).
For more information, see the following:
Configuring Logging
Use the EclipseLink logging framework to record EclipseLink behavior to a log file or session console.
This table summarizes which sessions support logging configuration.
Session | Using the Workbench |
Using Java |
---|---|---|
Note: If the session belongs to a session broker, you must specify the logging information in the session broker – not in the session itself. |
By default, EclipseLink uses its own native logger. Alternatively, you can configure EclipseLink to use the java.util.logging package.
For more information, see Logging.
How to Configure Logging Using Workbench
To specify the logging information for a session, use this procedure:
- Select a database session in the Navigator. Its properties appear in the Editor.
- Click the Logging tab. The Logging tab appears.
Logging Tab
Logging Tab - Complete the Logging fields on the tab.
Use the following information to enter data in each field of the Logging tab to select the profiler option to use with this session:
Option | Description |
---|---|
No Logging | Select this option to specify that nothing is logged for this session. |
Server | Select this option to use logging capabilities of the application server to which you are deploying this application. |
Java | Select this option to use java.util.logging package. |
Standard |
Select this option to use the EclipseLink logging framework. When selected, you can optionally configure the following options. |
|
Define the amount of logging information to record (in ascending order of information):
|
|
Select this option to display logging information to the standard console output. |
|
Select this option to record logging information in a file. Click Browse to specify the name and location of the log file. |
Options | Select this option to override additional logging option defaults for Java and Standard logging only. |
|
Select this option to include the stack trace with any exception written to the log. Default: For SEVERE messages, log stack trace. For WARNING messages, only log stack trace at log level FINER or lower. |
|
Select this option to include the connection identifier in any connection related log messages. Default: Enabled for all message and log levels. |
|
Select this option to include the date and time at which the log message was generated. Default: Enabled for all message and log levels. |
|
Select this option to include the session name in any session related log messages. Default: Enabled for all message and log levels. |
|
Select this option to include the thread name in any thread related log messages. Default: Log only at log level FINER or lower. |
How to Configure Logging Using Session API in Java
If you use EclipseLink native logging (the default), then at run time, you can configure logging options using org.eclipse.persistence.sessions.Session logging API.
The Session interface defines the following logging methods:
- setSessionLog – specify the type of logging to use (any implementor of org.eclipse.persistence.logging.SessionLog)
- dontLogMessages – disable logging
- setLog – specify the java.io.Writer to which the session logs messages
- setLogLevel – specify the level at which the session logs using org.eclipse.persistence.logging.SessionLog constants:
- OFF
- SEVERE
- WARNING
- INFO
- CONFIG
- FINE
- FINER
- FINEST
- ALL
This example illustrates how to configure a session to use java.util.logging package.
Configuring a Session to Use java.util.logging
session.setSessionLog(new JavaLog());
This example illustrates how to configure a session to use the server log that OC4J provides. For more information about server logging, see Server Logging.
Configuring a Session to Use Application Server Logging
session.setSessionLog(new OjdlLog());
This example illustrates how to configure a session to log to a java.io.Writer:
Configuring a Session to Log to a java.io.Writer
session.setLog(myWriter);
How to Configure a Session to use the java.util.logging Package
If you use java.util.logging package, then you configure logging options in the <JRE_HOME>/lib/logging.properties file. Messages are written to zero or multiple destinations based on this configuration file.
If you configure a session to use java.util.logging package, consider the following:
logging.properties
Configure the logging.properties file as this example illustrates:
java.util.logging Configuration in logging.properties
handlers = java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level = CONFIG java.util.logging.ConsoleHandler.formatter = org.eclipse.persistence.logging.LogFormatter org.eclipse.persistence.LoggingSession.connection.level = CONFIG
For information about the types of formatters available, see Formatters.
Formatters
EclipseLink provides two formatters: LogFormatter and XMLLogFormatter. They override the SimpleFormatter and XMLFormatter java.util.logging formatters and always log session and connection info when available. They also log thread and exception stack trace information at certain levels as specified by the logging level.
Namespace
Namespace is supported for java.util.logging. This table lists the static constants defined in org.eclipse.persistence.sessions.SessionLog for EclipseLink components and the corresponding strings in logging.properties.
Logging Property FIle Names
SessionLog | logging.properites |
---|---|
Not Applicable |
org.eclipse.persistence |
Not Applicable |
org.eclipse.persistence.<sessionname> |
SQL |
org.eclipse.persistence.<sessionname>.sql |
TRANSACTION |
org.eclipse.persistence.<sessionname>.transaction |
EVENT |
org.eclipse.persistence.<sessionname>.event |
CONNECTION |
org.eclipse.persistence.<sessionname>.connection |
QUERY |
org.eclipse.persistence.<sessionname>.query |
CACHE |
org.eclipse.persistence.<sessionname>.cache |
PROPAGATION |
org.eclipse.persistence.<sessionname>.propagation |
SEQUENCING |
org.eclipse.persistence.<sessionname>.sequencing |
EJB |
org.eclipse.persistence.<sessionname>.ejb |
EJB_OR_METADATA |
org.eclipse.persistence.<sessionname>.ejb_or_metadata |
WEAVER |
org.eclipse.persistence.<sessionname>.weaver |
PROPERTIES |
org.eclipse.persistence.<sessionname>.properties |
SERVER |
org.eclipse.persistence.<sessionname>.server |
In the logging.properties names listed in the Logging Property FIle Names table, note that <sessionname> is the name of the session that the application is running in. For example, if the name of the session is MyApplication, then you would use org.eclipse.persistence.MyApplication.sql for the SQL logging property.
An application can also define its own namespace and write to it through the logging API, as long as the logger for that namespace is defined in the logging configuration. Otherwise messages are written to the parent logger, org.eclipse.persistence.<sessionname>.
Configuring Multiple Mapping Projects
Each session is associated with at least one mapping project. You can include additional EclipseLink mapping projects for a session.
This table summarizes which sessions support additional mapping project configuration.
Session | Using the Workbench |
Using Java |
---|---|---|
How to Configure Multiple Mapping Projects Using Workbench
To specify additional EclipseLink projects for your session, use this procedure:
- Select a server or database session in the Navigator. Its properties appear in the Editor.
- Click the General tab. The General tab appears.
- Click the Project subtab. The Project subtab appears.
General Tab, Project Subtab, Multiple Projects Options - Select Multiple Projects option. The Multiple Projects subtab appears.
- Click the Multiple Projects subtab.
- To add an additional mapping project to this session, click Add. For more information, see Configuring a Primary Mapping Project.
To remove EclipseLink mapping projects, select the project file and click Remove.
How to Configure Multiple Mapping Projects Using Java
Using Java, you can register descriptors from more than one project with a session using the DatabaseSession API that this table lists. You can register descriptors before login, but you can add independent sets of descriptors after login.
DatabaseSession API for Registering Descriptors
Session Method | Description |
---|---|
addDescriptors(Project) |
Add additional descriptor to the session in the form of a project. |
addDescriptors(Vector) |
Add a vector of individual descriptor files to the session in the form of a project. |
addDescriptor(Descriptor) |
Add individual descriptor to the session. |
Configuring a Performance Profiler
To successfully improve the performance of an EclipseLink application, you must measure performance before and after each optimization. EclipseLink provides a variety of built-in performance measuring features (known as profilers) that you can configure at the session level.
This table summarizes which sessions support performance profiler configuration.
Session | Using the Workbench |
Using Java |
---|---|---|
EclipseLink provides the following profilers:
- EclipseLink profiler: logs performance statistics for every executed query in a given session (see Measuring EclipseLink Performance with the EclipseLink Profiler)
How to Configure a Performance Profiler Using Workbench
To specify the type of profiler in a session, use this procedure:
- Select a session in the Navigator. Its properties appear in the Editor.
- Click the Options tab. The Options tab appears.
Options Tab, Profiler Options - Complete the Profiler field on the tab.
Use the following information to select the profiler option to use with this session:
Option | Description |
---|---|
No Profiler | Disable all profiling. |
Standard (EclipseLink) |
Enable EclipseLink profiling. For more information, see the following: |
How to Configure a Performance Profiler Using Java
You can use Java to configure a session with a profiler using Session method setProfiler, as this example shows.
Configuring a Session with an EclipseLink Profiler
session.setProfiler(new PerformanceProfiler());
To end a profiling session, use Session method clearProfiler.
Configuring an Exception Handler
You can associate a single exception handling class with each session. This class must implement the org.eclipse.persistence.exceptions.ExceptionHandler interface.
This table summarizes which sessions support exception handler configuration.
Session Support for Exception Handler Configuration
Session | Using the Workbench |
Using Java |
---|---|---|
For an example exception handler implementation, see Using Java.
For more information, see Exception Handlers.
How to Configure an Exception Handler Using Workbench
To specify the exception handler class in a session, use this procedure:
- Select a session in the Navigator. Its properties appear in the Editor.
- Click the Options tab. The Options tab appears.
Options Tab, Exception Handler Field - Complete the Exception Handler field.
- Click Browse and select the exception handler class for this session.
How to Configure an Exception Handler Using Java
This example shows an example exception handler implementation. In this implementation, the exception handler always tries to reestablish the connection if it has been reset by peer, but only retries a query if it is an instance of ReadQuery. Note that this exception handler either returns the result of the reexecuted ReadQuery or throws an exception.
Implementing an Exception Handler
session.setExceptionHandler( new ExceptionHandler() { public Object handleException(RuntimeException exception) { if (exception instanceof DatabaseException) { DatabaseException dbex = (DatabaseException) exception; if ((dbex.getInternalException() instanceof SQLException) && (((SQLException) dbex.getInternalException()).getErrorCode() == MyDriver.CONNECTION_RESET_BY_PEER)) { dbex.getAccessor().reestablishConnection(dbex.getSession()); if (dbex.getQuery() instanceof ReadQuery) { return dbex.getSession().executeQuery(dbex.getQuery(), dbex.getQuery().getTranslationRow()); } throw exception; } } throw exception; } } );
Note: Unhandled exceptions must be rethrown by the exception handler code. |
Configuring a Session Customizer Class
A session customizer class is a Java class that implements the org.eclipse.persistence.internal.sessions.factories.SessionCustomizer interface and provides a default (zero-argument) constructor. You can use a session customizer to customize a session at run time on a loaded session before login occurs, similar to how you can use an amendment method to customize a descriptor) For example, you can use a session customizer class to define and register session event listeners with the session event manager (see Configuring Session Event Listeners).
This table summarizes which sessions support customizer class configuration.
Session Support for Customizer Class Configuration
Session | Using the Workbench |
How to Use Java |
---|---|---|
For more information, see Session Customization.
How to Configure Customizer Class Using Workbench
To specify the session customizer class in a session, use this procedure:
- Select a session in the Navigator. Its properties appear in the Editor.
- Click the Options tab. The Options tab appears.
Options Tab, Session Customizer Class Field - Complete the Session Customizer Class field.
- Click Browse and select the customizer class for this session.
How to Configure Customizer Class Using Java
When using Java, create a customize class that implements the org.eclipse.persistence.internal.sessions.factories.SessionCustomizer interface. This example illustrates the creation of the session customizer. The customize method contains the configuration of the Login owned by the Session with the appropriate transaction isolation.
Creating a SessionCustomizer Class
import org.eclipse.persistence.internal.sessions.factories.SessionCustomizer; import org.eclipse.persistence.sessions.Session; import org.eclipse.persistence.sessions.DatabaseLogin; public class EmployeeSessionCustomizer implements SessionCustomizer { public void customize(Sesssion session) { DatabaseLogin login = (DatabaseLogin)session.getDatasourceLogin(); login.setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_UNCOMMITTED); } }
Configuring the Server Platform
The EclipseLink server platform defines how a session integrates with a Java EE server including the following:
- Run-time services: Enables the deployment of a Java Management Extensions (JMX) MBean that allows monitoring of the EclipseLink session.
- External transaction controller: Integrates the EclipseLink session with the server's Java Transaction API (JTA) service. This should always be used when using EJB or JTA transactions. You configure EclipseLink to integrate with the container's external transaction service by specifying an EclipseLink external transaction controller. For more information on external transaction services, see Unit of Work Transaction Demarcation.
This table summarizes which sessions support a server platform.
Session Support for Server Platform
Session | Using the Workbench |
Using Java |
---|---|---|
How to Configure the Server Platform Using Workbench
To specify the server platform options for a session, use this procedure:
- Select a session in the Navigator. Its properties appear in the Editor.
- Click the General tab. The General tab appears.
- Click the Server Platform subtab. The Server Platform subtab appears.
General Tab, Server Platform Subtab - Enter complete each field on the Server Platform subtab.
Use the following information to enter data in each field of the Server Platform subtab:
Field | Description |
---|---|
Server Platform |
Check this field if you intend to deploy your application to a Java EE application server. If you check this field, you must configure the target application server by selecting a Platform. |
|
Select the Java EE application server to which you will deploy your application. EclipseLink supports the following Java EE application servers:
EclipseLink supports the following Java Servlet container servers: For detailed information about supported application server versions and configuration requirements, see Integrating EclipseLink with an Application Server. The server platform you select overrides the default server platform set at the sessions configuration leve. |
|
Check this field to configure the EclipseLink runtime to enable the deployment of a JMX MBean that allows monitoring of the EclipseLink session.
|
|
Check this field if you intend to integrate your application with an external transaction controller. For more information, see Unit of Work Transaction Demarcation. If you configure Platform for a Java EE application server that EclipseLink supports, the EclipseLink runtime will automatically select the appropriate external transaction controller class. If you configure Platform as Custom, you must specify an external transaction controller class by selecting an External Transaction Controller. |
|
This option is only available if you configure Platform as Custom. Click Browse to select your custom ServerPlatform class. |
|
This option is only available if you configure Platform as Custom. If you checked Enable External Transaction Controller (JTA), click Browse to select the transaction controller class that corresponds with your custom ServerPlatform class. |
How to Configure the Server Platform Using Java
When using Java, you must pass the session in a server platform constructor. This example illustrates using a session customizer (see Using the Session Customizer Class) to configure a session with a server platform from the org.eclipse.persistence.platform.server package.
Configuring a Session with a Server Platform
import org.eclipse.persistence.internal.sessions.factories.SessionCustomizer; ... public class MySessionCustomizer implements SessionCustomizer { public void customize (Session session) { Server server = (Server)session; server.setServerPlatform(new Oc4j_11_1_1_Platform(DatabaseSession)server)): } }
Configuring Session Event Listeners
As you perform persistence operations with a session, the session produces various events (see Session Event Manager Events) that the EclipseLink runtime uses to coordinate its various components. You can configure a session with one or more session event listeners to customize session behavior and debug session operations. For example, session event listeners play an important role in the configuration of isolated sessions.
This table summarizes which sessions support event listeners (SessionEventListener).
Session Support for Event Listeners
Session | Using the Workbench |
Using Java |
---|---|---|
How to Configure Session Event Listeners Using Workbench
Session Event Listeners
To specify the event listener class in a session, use this procedure:
- Select a session in the Navigator. Its properties appear in the Editor.
- Click the Options tab. The Options tab appears.
Options Tab, Event Listeners field - To add a new event listener, click Add, then select the event listener class for this session.
To remove an existing event listener, select the Event Listener and click Remove.
How to Configure Session Event Listeners Using Java
This example illustrates how to use Java to register a session event listener with a session. EclipseLink provides a SessionEventAdapter to simplify creating a SessionEventListener. The SessionEventAdapter provides a default implementation of all the methods of the SessionEventListener interface. You need only override the specific methods of interest. Typically, you would define session event listeners in a session customizer class.
Using the Session Event Adapter to Create a Session Event Listener
... SessionEventAdapter myEventListener = new SessionEventAdapter() { // Listen for PostCommitUnitOfWork events public void postCommitUnitOfWork(SessionEvent event) { // Call the handler routine unitOfWorkCommitted(); } }; mySession.getEventManager().addListener(myEventListener); ...
For information on how to add logging to your listeners, see Logging.
Configuring the Integrity Checker
When you log into a session, EclipseLink initializes and validates the descriptors you registered with it. By configuring the integrity checker, you can customize this validation process to do the following:
This table summarizes which sessions support descriptor integrity checking configuration.
Session Support for Checking Descriptor Integrity
Session | Using the Workbench | Using Java |
---|---|---|
Check Database
The IntegrityChecker method setShouldCheckDatabase specifies whether or not the integrity checker should verify the descriptor's metadata against the database metadata. This will report any errors due to missing or incorrect table or fields specified in the descriptors. This is turned off by default as it adds a significant overhead to connecting a session.
Catch All Exceptions
By default, the integrity checker catches all exceptions that occur during initialization, and throws a single exception at the end of initialization reporting all of the errors detected. If you only want the first exception encountered, you can disable this feature using IntegrityChecker method setShouldCatchExceptions(false).
Catch Instantiation Policy Exceptions
By default, the integrity checker tests the default or configured constructor for each descriptor initialized in the session. To disable this feature, use IntegrityChecker method setShouldCheckInstantiationPolicy(false).
How to Configure the Integrity Checker Using Java
As this example shows, you can configure the integrity checker validation process.
Configuring the Integrity Checker
session.getIntegrityChecker().setShouldCheckDatabase(true); session.getIntegrityChecker().setShouldCatchExceptions(false); session.getIntegrityChecker().setShouldCheckInstantiationPolicy(false); session.login();
Configuring Connection Policy
Using a connection policy, you can control how an EclipseLink session acquires and uses read and write connections, including the following:
This table summarizes which sessions support connection policy configuration.
Session Support for Connection Policy
Session | Using Workbench |
Using Java |
---|---|---|
Exclusive Write Connections
An exclusive connection is one that EclipseLink allocates to a client session for reading (of isolated data) and writing for the duration of the client session's life cycle.
By default, exclusive connections are not used and a client session uses the server session's read connection pool for all non-pessimistic read queries. A connection is obtained from the read connection pool for each read query execution and released back to the pool after the query is executed. A connection is only obtained from the write connection pool for the unit of work commit operation, or, potentially, earlier if data modify queries, or read queries using pessimistic locking are used. The connection will be release back to the write connection pool after the unit of work is committed or released. Exclusive connections are provided for use with database read security or Virtual Private Database (VPD) support. When using an exclusive connection, you will obtain it from the server session's write connection pool. When you acquire the client, the exclusive connection will be used for read queries to isolated classes (see Isolated Client Sessions), exclusive read queries, pessimistic read queries, and for the unit of work commit operation. The exclusive connection will only be released when the client session is released. EclipseLink still acquires a shared connection from the read connection pool for reading nonisolated data. If you use a JTA-managed external connection pool with exclusive connections, do not reuse a client session across JTA transaction boundaries, as the physical JTA database connection is released and acquired from the connection pool relative to the JTA transaction life cycle. A new client session, or the active unit of work, should be used for each JTA transaction. For more information, see Configuring Exclusive Read Connections.
You can also configure exclusive connections on a client-session-by-client-session basis (see How to Acquire a Client Session that Uses Exclusive Connections) and for named queries (see Configuring Named Query Advanced Options).
Note: If any client session contains an exclusive connection, you must release the session (see Logging Out of a Session) when you are finished using it. We do not recommend relying on the finalizer to release the connection when the session is garbage-collected. If you are using an active unit of work in a JTA transaction, you do not need to release the client session--the unit of work will release it after the JTA transaction completes. |
Lazy Connection Acquisition
By default, EclipseLink acquires write connections lazily, when you perform the first unit of work commit operation, exclusive read query, or pessimistic read query with your client session. The write connection will also be released after each unit of work it committed or released.
Alternatively, you can configure EclipseLink to acquire the write connection at the time you acquire a client session, and release the connection when you release the client session.
You can also configure lazy connection acquisition on a client-session-by-client-session basis (see How to Acquire a Client Session that Does Not Use Lazy Connection Allocation).
How to Configure Connection Policy Using Workbench
To specify the connection policy in a session, use this procedure:
- Select a session in the Navigator. Its properties appear in the Editor.
- Click the Connection Policy tab. The Connection Policy tab appears.
Connection Policy Tab
How to Configure Connection Policy Using Java
To configure whether or not an exclusive connection is allocated to a particular isolated session, use the org.eclipse.persistence.sessions.server.ConnectionPolicy method setExclusiveMode. You can set the ExclusiveMode to one of the following:
- Transactional - triggers the creation of a ClientSession.
You can also enable this option by selecting Acquire Connections Lazily in Workbench. - Isolated - triggers the creation of an ExclusiveIsolatedClientSession.
You can also enable this option by selecting Acquire Exclusive Connection in Workbench. - Asways - also triggers the creation of an ExclusiveIsolatedClientSession. Note that this mode allows the usage of an exclusive connection without requiring isolation.
You cannot use Workbench to set this option.
To define a map of properties used to support an isolated session, use the following ConnectionPolicy methods:
- setProperty(Object key, Object value): Adds the property value to the Map under key, overwriting the existing value if key already exists in the Map.
Note that these properties are not specifically geared toward an isolated client session. EclipseLink runtime makes them available during the creation of a client session in a PostAcquireExclusiveConnection event, but does not pass them to any event. Instead, it keeps these properties in the ConnectionPolicy, which, in turn, is kept by the client session. - Object getProperty(Object key): Returns the value associated with key as an Object.
- boolean hasProperties: Returns true if one or more properties exist in the Map; otherwise returns false.
The EclipseLink runtime passes this Map into SessionEvent events PostAcquireExclusiveConnection and PreReleaseExclusiveConnection so that your implementation can make the appropriate PL/SQL calls to the underlying database platform (see Using PostAcquireExclusiveConnection Event Handler and Using PreReleaseExclusiveConnection Event Handler).
To configure the session to use a named connection pool, use the ConnectionPool constructor that takes a String connection pool name as an argument, as follows:
Session clientSession = server.acquireClientSession(new ConnectionPolicy("myConnectionPool"));
Configuring Named Queries at the Session Level
A named query is an EclipseLink query that you create and store, by name, in a session for later retrieval and execution. Named queries improve application performance, because they are prepared once and they (and all their associated supporting objects) can be efficiently reused thereafter making them well-suited for frequently executed operations.
If a named query is global to a project, configure it at the session level. Alternatively, you can configure a named query at the descriptor level (see Configuring Named Queries at the Descriptor Level).
Use named queries to specify SQL, EJB QL, or EclipseLink Expression queries to access your data source.
This table summarizes which sessions support named query configuration.
Session | Using the Workbench | Using Java |
---|---|---|
After you create a named query, you can execute it by name on the EclipseLink session (see Using Named Queries).
For more information about named queries, see Named Queries.
How to Configure Named Queries at the Session Level Using Java
You can store a query by name in a Session using Session method addQuery(String name, DatabaseQuery query).