Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/DBWS/Using SessionCustomizer"

m
m (Replacing page with 'For the current version, see: '''[http://www.eclipse.org/eclipselink/documentation/2.4/dbws/toc.htm Developing Persistence Architectures Using EclipseLink Database Web Services...')
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{EclipseLink_UserGuide
+
For the current version, see:
|info=y
+
'''[http://www.eclipse.org/eclipselink/documentation/2.4/dbws/toc.htm Developing Persistence Architectures Using EclipseLink Database Web Services, Release 2.4]'''
|toc=n
+
|eclipselink=y
+
|eclipselinktype=DBWS
+
}}
+
  
==Using an EclipseLink SessionCustomizer==
+
For "Using an EclipseLink SessionCustomizer," see http://www.eclipse.org/eclipselink/documentation/2.4/dbws/creating_dbws_services002.htm
When using an EclipseLink <tt>SessionCustomizer</tt> with DBWS, you can access to the EclipseLink API to retrieve the OR (object-relational) or OX (object-XML) mapping descriptors from the session. You can then use the descriptors to add, change, or delete mappings.  
+
  
Refer to the [http://wiki.eclipse.org/Introduction_to_EclipseLink_Sessions_%28ELUG%29#Session_Customization EclipseLink Documentation] for details on the <tt>SessionCustomizer</tt>.
+
[[Category:DBWS]]
===Example===
+
This example illustrates how to implement an EclipseLink <tt>SessionCustomizer</tt>:
+
 
+
<source lang="java">
+
package some.java.package;
+
+
import org.eclipse.persistence.config.SessionCustomizer;
+
import org.eclipse.persistence.sessions.Session;
+
import org.eclipse.persistence.sessions.DatabaseLogin;
+
+
public class MySessionCustomizer implements SessionCustomizer {
+
+
  public MySessionCustomizer() {
+
  }
+
+
  public void customize(Sesssion session) {
+
    DatabaseLogin login = (DatabaseLogin)session.getDatasourceLogin();
+
    // enable 'dirty' reads
+
    login.setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_UNCOMMITTED);
+
  }
+
}
+
</source>
+
 
+
In the '''DBWSBuilder''' configuration file, you must use the '''orSessionCustomizerClassName''' or '''oxSessionCustomizerClassName''' to specify if the customization applies to the ORM or ORX project (respectively), as shown here:
+
 
+
'''ORM Project'''
+
<source lang="xml">
+
<?xml version="1.0" encoding="UTF-8"?>
+
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
  <properties>
+
    <property name="projectName">customize_test</property>
+
    ...
+
    <property name="orSessionCustomizerClassName">some.java.package.MyORSessionCustomizer</property>
+
</source>
+
 
+
'''ORX Project'''
+
<source lang="xml">
+
<?xml version="1.0" encoding="UTF-8"?>
+
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
  <properties>
+
    <property name="projectName">customize_test</property>
+
    ...
+
    <property name="oxSessionCustomizerClassName">some.java.package.MyOXSessionCustomizer</property>
+
</source>
+

Latest revision as of 08:46, 1 November 2012

For the current version, see: Developing Persistence Architectures Using EclipseLink Database Web Services, Release 2.4

For "Using an EclipseLink SessionCustomizer," see http://www.eclipse.org/eclipselink/documentation/2.4/dbws/creating_dbws_services002.htm

Back to the top