Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Storing Sessions in the Session Manager Instance

Although Oracle recommends that you export all session instances from TopLink Workbench to one or more sessions.xml files, alternatively, you can manually create a session in your application and, as Example 78-13 illustrates, manually store it in the session manager using SessionManager method addSession. Then, you can acquire a session by name using the SessionManager method getSession.


Note:

The addSession method is not necessary if you are loading sessions from a session configuration file.

Example 78-13 Storing Sessions Manually in the Session Manager

// create and log in to the session programmatically
Session theSession = project.createDatabaseSession();
theSession.login();
// store the session in the SessionManager instance
SessionManager manager = SessionManager.getManager();
manager.addSession("mysession", theSession);
// retrieve the session
Session session = SessionManager.getManager().getSession("mysession");