Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA + Native interference(JPA mappings interfering with Native Workbench Mappings)
JPA + Native interference [message #1001854] Thu, 17 January 2013 12:57 Go to next message
Roger Spall is currently offline Roger SpallFriend
Messages: 17
Registered: January 2013
Junior Member
To summarize, I am working on a project to migrate from Native Eclipselink (Mapping workbench / Native Eclipselink queries / ExpressionBuilders, ReadObject queries, etc) to JPA.

Anyway, the migration plan requires that the same POJO business objects are (temporarily) mapped through both JPA AND Mapping workbench / Native mappings - in this case we are using the old 'Project java source' generated from the Mapping Workbench to represent the runtime native mappings.

Without excessive detail, we basically want to facilitate testing so we can compare POJO's persisted through both the old Native EclipseLink and new JPA, and confirm no JPA mapping errors exit - unfortunately there are hundreds of POJOs and we have to manually create the new JPA POJO mappings from the old Native Mapping Workbench project!

Anyway we have run into an annoying problem...

We had assumed (no documentation / spec anywhere about this) that both Native and JPA projects / mappings can co-exist for the same POJO's provided we use the different methods for accessing them, i.e. an EntityManager (JPA) versus an EclipseLink Server / sessions. Obviously our old code works just fine, and we just added special test cases using an EntityManager to compare old to new persisted POJOs.

What we have found is that marking a POJO relationship as Transient in JPA also causes that same POJO relationship to be null / transient in Native Eclipselink.

Imagine a Bank with a collection of Accounts. This collection is mapped as a 1 - many relationship in the MappingWorkbench and has been working fine for years in production - read via Native Eclipselink queries. Now we have added a JPA mapping for Bank, but marked this Accounts relationship as Transient. Of course, as expected reading any Bank objects through JPA / EntityManager we find null Accounts. However, we now find that reading any Bank objects in Native Eclipselink (our old code) suddenly returns Banks with null / no Accounts! When I remove this JPA transient marker for a Bank's Accounts, the problem goes away.

Can anyone cast light on this issue and / or confirm that you cannot have the same POJO's mapped with both JPA and Native mappings at the same time?


1) Just in case someone astutely observes that if it hurts when you hit your head against the wall, just stop hitting your head Smile
** With so many Natively mapped POJO's we really need a testing strategy to make sure that the new JPA mappings correctly correspond to the old Native mappings. This means we have to compare old and new mappings for the same POJO's in the same codebase, AND it makes it simpler if we convert all of the primitive mappings (setting relationships to Transient) and test those first, before we compare the relationships.

2) It makes no difference whether we use JPA annotations or ORM.xml, Trnsient causes the same problem either way

3) Marking a primitive as Transient / unmapped in JPA doesn't stop Native Eclipselink from correctly loading that primitive's value, i.e. Transient only breaks Native Eclipselink relationships

4) No surprises, but just to be sure, when I use an ORM.xml file and map the POJO using a different JPA provider, Transient doesn't impact Native Eclipselink mappings
- This may end up being our work around, i.e. test our mappings by comparing the same POJOs mapped through Native Eclipselink and a non-eclipselink JPA (e.g. OpenJPA).
- Once this part of the testing is complete (old mappings are equivalent to and return identical content to JPA mappings) we can switch off / out the Native Eclipselink mappings and switch the JPA provider back to Eclipselink
Re: JPA + Native interference [message #1001893 is a reply to message #1001854] Thu, 17 January 2013 14:17 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

@Transient should have no affect on the native API. My only guess is that weaving is somehow affecting the relationship, try disabling weaving in JPA to confirm this.

Are you using indirection in the native API? Do you have the attribute defined as a ValueHolderInterface? How are you mapping the same relationship in JPA?
May be related to change tracking or cloning, disabling weaving of change tracking or internal would confirm. You may need to set the change policy explicitly in your native project to avoid it being defaulted.

James : Wiki : Book : Blog : Twitter
Re: JPA + Native interference [message #1002047 is a reply to message #1001893] Thu, 17 January 2013 20:26 Go to previous messageGo to next message
Roger Spall is currently offline Roger SpallFriend
Messages: 17
Registered: January 2013
Junior Member

Thanks for the prompt reply...

For the Native API:
Two relationships are straight 1-1 (No Value Holder indirection), the other is a Collection which is mapped with Indirection through the workbench

ALL values are null in the business object when I have the same POJO mapped with both Native and JPA (eclipse provider). When I switch the JPA provider to openJPA the problem goes away.

As you suggested, I turned off weaving and the problem went away:

<property name="eclipselink.weaving" value="false"/>

So JPA mappings are interfering with Native Eclipse mappings when the same POJO is mapped through both JPA and Native Eclipse - at least when JPA says Transient (in the orm.xml) it causes Native Eclipse to also be transient (i.e. no longer mapped).


- What do I lose with turning off weaving?
- Should it be possible to map the same POJO's through Native Eclipse and JPA and read them independently, one throuh EntityManager and the other through EclipseLink Server / sessions?
- I know it is unusual, and it will only be a temporary design for testing!
Re: JPA + Native interference [message #1004084 is a reply to message #1002047] Tue, 22 January 2013 14:53 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

With weaving off you loose LAZY on OneToOne and ManyToOne relationships, and loose some performance optimizations.

I would figure out which weaving is causing the issue first, leave weaving enabled, but just disable parts separately,

<property name="eclipselink.weaving.internal" value="false"/>
<property name="eclipselink.weaving.lazy" value="false"/>
<property name="eclipselink.weaving.changetracking" value="false"/>

James : Wiki : Book : Blog : Twitter
Previous Topic:EclipseLink and pagined queries
Next Topic:tenant property not found on cascading delete
Goto Forum:

Current Time: Sun Jun 24 07:40:56 GMT 2018

Powered by FUDForum. Page generated in 0.01894 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top