|
|
(3 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>
| + | |
− | | + | |
− | | + | |
− | ==Advanced Customization==
| + | |
− | You can further customize an EclipseLink DBWS service by creating your own EclipseLink '''project.xml''' and '''sessions.xml''' files. Using your preferred utility, you can do the following:
| + | |
− | * map your objects to your relational database in an EclipseLink relational project;
| + | |
− | * map your objects to your XML schema in an EclipseLink XML project:
| + | |
− | * create an EclipseLink '''sessions.xml''' file that references both projects.
| + | |
− | | + | |
− | In this way, you can control all aspects of the relational and XML mapping. This approach is best when you want to customize most or all details.
| + | |
− | | + | |
− | ===Example===
| + | |
− | In this example, a DBWS service is constructed from existing EclipseLink project maps with identical case-sensitive aliases (for Descriptors that are common between the projects).
| + | |
− | | + | |
− | <source lang="xml">
| + | |
− | <?xml version="1.0" encoding="UTF-8"?>
| + | |
− | <object-persistence version="Eclipse Persistence Services - some version (some build date)" xmlns="http://www.eclipse.org/eclipselink/xsds/persistence" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:eclipselink="http://www.eclipse.org/eclipselink/xsds/persistence">
| + | |
− | <name>SomeORProject</name>
| + | |
− | <class-mapping-descriptors>
| + | |
− | <class-mapping-descriptor xsi:type="relational-class-mapping-descriptor">
| + | |
− | <class>some.package.SomeClass</class>
| + | |
− | <alias>SomeAlias</alias>
| + | |
− | ...
| + | |
− | | + | |
− | <?xml version="1.0" encoding="UTF-8"?>
| + | |
− | <object-persistence version="Eclipse Persistence Services - some version (some build date)" xmlns="http://www.eclipse.org/eclipselink/xsds/persistence" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:eclipselink="http://www.eclipse.org/eclipselink/xsds/persistence">
| + | |
− | <name>SomeOXProject</name>
| + | |
− | <class-mapping-descriptor xsi:type="xml-class-mapping-descriptor">
| + | |
− | <class>some.package.SomeClass</class>
| + | |
− | <alias>SomeAlias</alias>
| + | |
− | ...
| + | |
− | </source>
| + | |
− | | + | |
− | '''Note:''' When building a DBWS web service in this way (that is, without the '''DBWSBuilder Utility''', be sure to create all the necessary deployment artifacts.
| + | |