Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » TopLink migration to Eclipselink (TopLink migration to Eclipselink )
TopLink migration to Eclipselink [message #1858885] Fri, 28 April 2023 08:58 Go to next message
Sanjana C is currently offline Sanjana CFriend
Messages: 31
Registered: December 2022
Member
Hi Team,

In our application , we are removing toplink dependency and migrating to eclipselink.

In toplink , we have single xml where we declare class-mapping-descriptors for all entity classes .

But in eclipselink , what i did is i used annotations and other matadeta related to entity in class that implements DescriptorCustomizer .So each entity has different metadata that lead to different class that implements DescriptorCustomizer.


Do we have any xml with tags in eclipselink where in one file we can add all metadata?

I see somthing called ecliplink-orm.xml file where we declare metadata but i didnot find any proper example to understand it.
Could you please let me know if you have any idea on this?


For your reference , we have xml file in toplink like below

<toplink:object-persistence version="Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)" xmlns:opm="http://xmlns.oracle.com/ias/xsds/opm" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:toplink="http://xmlns.oracle.com/ias/xsds/toplink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<opm:name></opm:name>
<opm:class-mapping-descriptors>
<opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
<opm:class></opm:class>
<opm:alias></opm:alias>
<opm:primary-key>
<opm:field table="" name="ID" xsi:type="opm:column"/>
</opm:primary-key>
<opm:events xsi:type="toplink:event-policy"/>
<opm:querying xsi:type="toplink:query-policy">
<opm:queries>
<opm:query name="findAll" xsi:type="toplink:read-all-query">
<toplink:reference-class></toplink:reference-class>
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>java.util.Vector</toplink:collection-type>
</toplink:container>
</opm:query>

</opm:queries>
</opm:querying>
<opm:attribute-mappings>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>id</opm:attribute-name>
<opm:field table="Kurstraeger" name="ID" xsi:type="opm:column"/>
</opm:attribute-mapping>

</opm:attribute-mappings>
<toplink:descriptor-type>independent</toplink:descriptor-type>
<toplink:locking xsi:type="toplink:timestamp-locking-policy">
<toplink:version-field table="" name="LOCKING_TIMESTAMP" xsi:type="opm:column"/>
<toplink:server-time>true</toplink:server-time>
</toplink:locking>
<toplink:sequencing>
<toplink:sequence-name></toplink:sequence-name>
<toplink:sequence-field table="" name="ID" xsi:type="opm:column"/>
</toplink:sequencing>
<toplink:caching>
<toplink:isolated>true</toplink:isolated>
<toplink:cache-invalidation-policy xsi:type="toplink:daily-cache-invalidation-policy">
<toplink:expiry-time xsi:type="xsd:dateTime">1970-01-01T02:00:00.0</toplink:expiry-time>
</toplink:cache-invalidation-policy>
<toplink:cache-sync-type>no-changes</toplink:cache-sync-type>
</toplink:caching>
<toplink:instantiation/>
<toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
<toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
<toplink:tables>
<toplink:table name=""/>
</toplink:tables>
</opm:class-mapping-descriptor>
</opm:class-mapping-descriptors>
</toplink:object-persistence>

Thansk,
Sanjana
Re: TopLink migration to Eclipselink [message #1858892 is a reply to message #1858885] Fri, 28 April 2023 17:51 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 54
Registered: December 2021
Member
EclipseLink was based on TopLink, so a true migration mostly just requires package renaming - all the older TopLink project/session xml files can be used with EclipseLink. See https://www.eclipse.org/eclipselink/documentation/2.7/solutions/migrnativetoplink001.htm#BCGGFGDG for details.

EclipseLink-orm.xml is new; an ORM.xml is JPA's 'project' xml, and allows you to define and override any/all mappings in entities - similar to how a project.xml worked in native TopLink. As JPA did not have all the same concepts and functionality TopLink (and so EclipseLink) built up over the years,, the EclipseLink-orm.xml is a JPA orm.xml mapping style of file, but extended to allow more configuration and customizations that isn't in the JPA spec. See https://www.eclipse.org/eclipselink/documentation/2.6/jpa/extensions/schema.htm and https://wiki.eclipse.org/EclipseLink/Examples/JPA/EclipseLink-ORM.XML for details.

If you already have a working session/project definition somehow in code, you can use EclipseLink to write it out as an orm or eclipselink-orm.xml. I only remember it is possible and not the details that would help get you started though if that is the approach you want to go (EclipseLink's own unit tests I believe are the starting point I had when doing something to dynamically create entities and orm.xml mappings).
Re: TopLink migration to Eclipselink [message #1859005 is a reply to message #1858892] Fri, 05 May 2023 07:57 Go to previous messageGo to next message
Sanjana C is currently offline Sanjana CFriend
Messages: 31
Registered: December 2022
Member
HI Chris,

Thanks for your reply .

As you suggested , i tried using same sessions.xml and descriptor file of toplink in eclipselink with just xsd changes .

Iam using spring along with eclipselink for transactions to be managed by spring.

So issue when i run junits is i see is classcastexceptions for eclipselink related classes which is not happenning when i use annotations .

For example

Exception Description: Unable to process XML tag [platform-class] with value [org.eclipse.persistence.platform.database.Oracle11Platform].
Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.platform.database.Oracle11Platform cannot be cast to org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform

same issue for attribute-transformer classes too.

Do something i need to set in spring xml to make the eclipselink classes visible to container .I have this below config set up entitymanager bean in applicationcontext.xml


<property name="jpaPropertyMap">
<props>
<prop key="eclipselink.weaving">false</prop>
</props>
</property>
<property name="loadTimeWeaver">
<bean class=
"org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>





Re: TopLink migration to Eclipselink [message #1859201 is a reply to message #1859005] Fri, 19 May 2023 00:12 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 54
Registered: December 2021
Member
Seems like a class loader issue occurring as org.eclipse.persistence.platform.database.Oracle11Platform certainly extends from the org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform class. You'll need to check how your Session is being loaded (if using native API, you might need to pass in a class loader to the SessionManager if I remember correctly) while your JPA container should be handling this for you - With Spring in the mix, I don't know, but they must be using one class loader in one spot and another elsewhere to cause this.
Previous Topic:Analyze Profiler Logs
Next Topic:Error calling PostgreSQL stored procedure
Goto Forum:
  


Current Time: Thu Apr 25 22:32:40 GMT 2024

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

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

Back to the top