Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be 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/Examples/DBWS/DBWSIntermediateCustomizer"

(New page: ===EclipseLink Session Customization=== The primary reason to use an EclipseLink <tt>SessionCustomizer</tt> is to enable programmatic access to the EclipseLink API. Using this API, you can...)
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<css>
 +
  .source-java5 {padding:4px;border:1px solid black; background-color: white;}
 +
  .source-xml {padding:4px;border:1px solid black; background-color: white;}
 +
  .source-text {padding:4px;border:1px solid black; background-color: white;}
 +
</css>
 +
__NOTOC__
 
===EclipseLink Session Customization===
 
===EclipseLink Session Customization===
 
The primary reason to use an EclipseLink <tt>SessionCustomizer</tt> is to enable programmatic access to the EclipseLink API. Using this API, you can retrieve the object-relational or object-XML mapping descriptors from the session, and then use these descriptors to add, change, or delete mappings. You could also consider turning off the session cache, or changing the transaction isolation level of the database connection.
 
The primary reason to use an EclipseLink <tt>SessionCustomizer</tt> is to enable programmatic access to the EclipseLink API. Using this API, you can retrieve the object-relational or object-XML mapping descriptors from the session, and then use these descriptors to add, change, or delete mappings. You could also consider turning off the session cache, or changing the transaction isolation level of the database connection.
  
 
The following example shows how to implement a <code>o.e.p.config.SessionCustomizer</code>:
 
The following example shows how to implement a <code>o.e.p.config.SessionCustomizer</code>:
 
+
<source lang="java5">
<source lang="java5" enclose="div">
+
 
package some.java.package;
 
package some.java.package;
  
Line 25: Line 30:
  
 
In the <tt>DBWSBuilder</tt> builder XML file, specify if the customization applies to the ORM project or the OXM project, as the following example shows:
 
In the <tt>DBWSBuilder</tt> builder XML file, specify if the customization applies to the ORM project or the OXM project, as the following example shows:
 
+
<source lang="xml">
<source lang="xml" enclose="div">
+
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
Line 34: Line 38:
 
     <property name="orSessionCustomizerClassName">some.java.package.MyORSessionCustomizer</property>  
 
     <property name="orSessionCustomizerClassName">some.java.package.MyORSessionCustomizer</property>  
 
</source>
 
</source>
 
 
or
 
or
 
+
<source lang="xml">
<source lang="xml" enclose="div">
+
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
Line 48: Line 50:
  
 
For details, see [[Introduction to EclipseLink Sessions (ELUG)#Session_Customization|Session Customization]].
 
For details, see [[Introduction to EclipseLink Sessions (ELUG)#Session_Customization|Session Customization]].
 +
 +
[[Category:EclipseLink/Example/DBWS]]

Latest revision as of 10:08, 7 October 2010


EclipseLink Session Customization

The primary reason to use an EclipseLink SessionCustomizer is to enable programmatic access to the EclipseLink API. Using this API, you can retrieve the object-relational or object-XML mapping descriptors from the session, and then use these descriptors to add, change, or delete mappings. You could also consider turning off the session cache, or changing the transaction isolation level of the database connection.

The following example shows how to implement a o.e.p.config.SessionCustomizer:

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); 
  } 
}

In the DBWSBuilder builder XML file, specify if the customization applies to the ORM project or the OXM project, as the following example shows:

<?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>

or

<?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>


For details, see Session Customization.

Back to the top