Skip to Content

With JPA as
the standard for object-relational persistence, you are in the comfortable
position of being able to choose your favorite implementation from a set of
well-established persistence providers. While every Java EE application server
is delivered with a JPA provider that is used per default, the Java EE standard
allows for exchanging the persistence provider on a per-application basis (or to
be precise: on a per-persistence unit basis). There might be good reason to
decide for another JPA implementation – be it that you would like to leverage a
certain feature of a particular provider, be it that you experience better
performance measures with that provider, or that you are simply more familiar
with it.

EclipseLink
is one of the most popular open source JPA providers. In this blog, I’ll guide
you step by step through the procedure how to use EclipseLink as a JPA provider
in SAP NetWeaver AS Java. I will also point you the limitations you have to be
aware of when using Eclipse Link in the NetWeaver server.


Required Versions


EclipseLink Version


EclipseLink
has to be aware of the specific application server environment in which it is
used. For that purpose, EclipseLink has separate ServerPlatform implementation
classes for the different application servers in the market. Starting with
EclipseLink 2.1.0, the adapter class for SAP NetWeaver AS Java is contained in
the standard EclipseLink delivery. We refer to this class as the NetWeaver
server platform.


SAP NetWeaver AS Java


Version


The
NetWeaver server platform is supposed to work with SAP NetWeaver 7.1 EHP 1 and
higher, although, at present, EclipseLink’s server test suite has only been
executed on version 7.2 and higher.


Procedure


In the
following, I’ll guide you step by step through the procedure how to use
EclipseLink as a JPA provider in SAP NetWeaver AS Java:


Download EclipseLink


You can
download EclipseLink from this location: http://www.eclipse.org/eclipselink/downloads/index.php

Make sure to
get EclipseLink version 2.1.0 or higher in order that the archive contains the
NetWeaver server platform class.


Package and Deploy


EclipseLink


As a next
step, you should package the eclipselink.jar file from the download in a way
that it can be deployed to the SAP NetWeaver AS Java server. We recommend that
you deploy it as a so called “shared library”, so that you have it centrally
available and can use it from multiple applications.

Follow the
instructions given in the SAP Help Portal to package EclipseLink as a shared
library and deploy it to your application server:

For SAP
NetWeaver 7.2: Using Shared Libraries (7.2) , section „Creating Shared Libraries”

For SAP
NetWeaver 7.1 EHP 1: Using Shared Libraries (7.1 EHP1) , section „Creating Shared
Libraries”</li></ul>


Add an Application


Reference


For SAP
NetWeaver 7.2: Using Shared Libraries (7.2) , section „Referencing Shared
Libraries”

For SAP
NetWeaver 7.1 EHP 1: Using Shared Libraries (7.1 EHP1) , section „Referencing Shared
Libraries”</li></ul>


Configure EclipseLink as JPA


Provider for Your Application


Limitations


Use JPA 1.0 Only


SAP
NetWeaver AS Java is a Java EE 5 application server and, as such, supports JPA
1.0 only. EclipseLink version 2.1.0 or higher, on the other hand, is a JPA 2.0
compliant JPA provider. However, due to the fact that JPA 2.0 is backward
compatible to JPA 1.0, it can act as a JPA 1.0 provider as well.

We strongly
recommend that you limit your application to the JPA 1.0 features. While you
might succeed to a certain degree even with leveraging selected JPA 2.0
features, you will most likely face some fundamental conceptual problems.


Use Static Weaving Instead


of Dynamic Weaving


EclipseLink
uses a byte-code manipulation technique called “weaving” for optimizing the
handling of JPA entities (including lazy loading of relations and attributes,
change detection and other performance optimizations). EclipseLink can perform
byte-code weaving either dynamically at runtime when the entity classes are
loaded, or statically at compile time of the application.

However, dynamic
weaving can’t be used inside SAP NetWeaver AS Java, so you should use static
weaving instead. See http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Weaving for more information on
EclipseLink’s weaving .</p>


Use Native SQL Instead of Open


SQL


EclipseLink
is not aware of SAP NetWeaver AS Java’s database abstraction framework known as
Open SQL and therefore generates SQL statements that are not compliant to the
Open SQL syntax. With EclipseLink you should therefore use a data source that
is defined with Native SQL (or Vendor SQL) as SQL engine type. In particular, that
means you can’t use the applications server’s system data source but have to
create a custom one. Refer to the SAP help portal for a description of how to work with data sources in SAP NetWeaver:


EclipseLink Is Not Covered


by SAP Support Agreements


You have to
be aware that EclipseLink is currently not covered by any support agreements
you have with SAP. Unless you have made special agreements, you are limited to
the regular support that you get in an open source community.


Get Involved!


Your
feedback on using EclipseLink within the NetWeaver server is very much
appreciated. We are interested in any issues you might have with the
integration but also in your ideas or suggestions for future enhancements. What
exactly is it that you need or that annoys you currently?

In most
cases, the appropriate channel for reporting problems with EclipseLink is the
Eclipse bug database Bugzilla . If you need further advice on using or
configuring EclipseLink, you can also consult the eclipselink-users
mailing list
.


Further Links



EclipseLink
project: http://www.eclipse.org/eclipselink/


EclipseLink
user guide: http://wiki.eclipse.org/EclipseLink/UserGuide


EclipseLink
download site: http://www.eclipse.org/eclipselink/downloads/index.php


NetWeaver
server platform: http://wiki.eclipse.org/EclipseLink/Development/ServerPlatform/NetweaverPlatform


Bugzilla:
https://bugs.eclipse.org/bugs/


eclipselink-users
mailing list: https://dev.eclipse.org/mailman/listinfo/eclipselink-users </li></ul>

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

  1. Rolf Paulsen
    Hi Sabine,

    thank you for your blog. The log and the contribution of you and your colleagues will help to increase the community of EclipseLink-Users on NetWeaver.

    We successfully use EL on NetWeaver 7.20 (before on 7.1 EHP 1) since the beginning of our project in October and can recommend it.

    The integration in NWDS “out of the box” is of course easy and best: With the JPA Facet turned on and after switching to EclipseLink in the “JPA” project properties, NWDS (Eclipse) provides a feature-rich persistence.xml-editor and good JPA validation, if you like these tools.

    There are many features we do not want to miss:
    – Orphan Removal (@PrivateOwned)
    – user defined types (@Converter)
    – drop-and-create tables (good for JUnit Tests) and generation of complete DDL-Skripts (incl. sequences)
    – good logging options
    – transparent support for lazy loading on ManyToOne and OneToOne Relations with byte code weaving
    – lazy loading even on detached objects (!)
    – no “heavy” class loading necessary (like required with hibernate)
    – last but not least good online documentation

    Here are some more points:

    * The limitation to static weaving is trivial in Eclipse and “normal” ant build but tricky if you work in NWDI: There is no documented way to leverage the Central Build Service to this weaving ant task. We addressed support for dynamic weaving at SAP and expect that this gap in the Java EE 5 implementation will be closed in the near future.

    * On Oracle Database, EL directly uses some Oracle features of the Oracle jdbc driver (at least in the elder version of EL that we currently use). So the ojdbc14.jar had to be visible to EL and bundled with eclipselink.jar. We will try shortly if this is still the case in EL 2.1.

    The support in the Java EE 5 forum is currently very good (not only in this topic) so it is a good time to start.

    Looking forward to a full support agreement 🙂

    Regards,
    Rolf

    (0) 
    1. Sabine Heider Post author
      Hi Rolf,

      Thanks for the positive feedback on EclipseLink! Your comment might encourage others to try it out as well.

      Regarding your issues:

      * We are going to work out a piece of documentation that describes how to use EclipseLink’s static weaving in an NWDI environment. This might be a reasonable workaround for the missing dynamic weaving support.

      * This is an interesting point. Please let us know if this setup causes any problems inside the NetWeaver server. We don’t have any practical experience with this combination yet, but we are willing to assist you wherever possible.

      Best regards,
      Sabine

      (0) 
      1. Rolf Paulsen
        Hi Sabine,

        * Thank you, this documentation would help us a lot.

        * No, there are no problems at all inside the NetWeaver server. The ojdbc14.jar just had to be bundled together with (=classpath-visible for) eclipselink, that’s all. (We bundle both into the ear’s lib folder.)

        Kind regards,
        Rolf

        (0) 
        1. Rolf Paulsen
          Hi,
          the issue with the direct reference to ojdbc14.jar on Oracle databases does not exist anymore in EclipseLink 2.1. There is no need to deploy it with EL.
          Greetings
          Rolf
          (0) 
      2. Rolf Paulsen
        Hi again,

        about the documentation for static weaving in NWDI: Can you give us a hint when this documentation will be available?

        Thanks and regards,
        Rolf

        (0) 
        1. Sabine Heider Post author
          Hi Rolf,

          difficult question 🙂 I can give you an idea of the status of the topic at least.

          We, i.e. the Java Persistence team, have just started to do some investigations on the topic. We have some input from NWDI colleagues that looks promising, but we have to work out a solution first. It’s too early to predict when (or if at all!) we will succeed with our efforts. In the best case, expect a blog or article within the next weeks – but without any guarantees.

          Regards,
          Sabine

          (0) 
  2. Kristian Rink
    …nice seeing SAP taking care of / dealing with JPA and EclipseLink; maybe this will push forth things talking about EclipseLink support for SAP MaxDB. 🙂
    KR
    (0) 
    1. Sabine Heider Post author
      Hi Kristian,

      as Rolf observed correctly SAP has already started working on the MaxDB Platform. It is still in incubation, but there has been significant progress and the status-quo looks quite promising. There are still a few failing tests in the EclipseLink test suite that we need to deal with, though.

      Once we are confident enough about the platform’s quality so that it can be promoted into EclipseLink’s product code base, we’ll let you know in another blog.

      Best regards,
      Sabine

      (0) 
      1. Kristian Rink
        Hi Sabine, Rolf;

        and thanks a bunch for your info. 🙂 So far, using (community version of) SAP MaxDB, the absence of JPA support always has been one of the top priority annoyances… Good to see there’s progress here. 🙂

        Kristian

        (0) 
  3. Kerstin Fender
    Hi Sabime,

    how can I force the server to give my an EntityManager for my persistence unit ?
    I have to do this because we use container managed persistence.

    @PersistenceContext(name=”entityManager”,unitName=”myUnit”)

    gives me wrong the EntityManager for built-in SAP implementation which works on system datasource.

    thanks
    Kerstin

    (0) 
  4. Kirill Zhuklinets
    Hi there!
    Could you say what should I EXACTLY write in the application-j2ee-engine.xml file? I have a eclispelink.jar file in the EAR project and I can’t find what I have to write to make a reference. Thank you in advance.
    (0) 

Leave a Reply