Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problem on EclipseLink JPA Weaving using Toplink session.xml, project.xml as JPA Source
Problem on EclipseLink JPA Weaving using Toplink session.xml, project.xml as JPA Source [message #538254] Mon, 07 June 2010 06:39 Go to next message
Jessie Yeung is currently offline Jessie Yeung
Messages: 8
Registered: June 2010
Junior Member
Hi all,

I encountered a problem to enable EclipseLink weaving using session.xml and project.xml as JPA source.

Background
Application Environment: OC4J 10.1.3.5 + EclipseLink 2.0 + Spring 2.5.6/3.0.2 + JPA

Firstly, I uses Toplink sessions.xml and project.xml as JPA source, defined in persistence.xml (no indirection) (Link: http://wiki.eclipse.org/EclipseLink/Examples/JPA/NativeMetad ata), the Spring project deployed in OC4J(10.1.3.5) works as expected (i.e. can perform insert/update/delete/query).

After that, I enable indirection (1-1: ValueHolder, 1-m, m-m: Transparent) in the project, export it to project.xml and replace new entity class source (have get/set methods to access the 1-1 attribute using ValueHolder). I test the indirection feature inside my Toplink 10g (no JPA) + Spring 2.5.6/3.0.2 project, the lazy loading works without problems.

However, when I try to use the same set of project.xml and entity class source into my EclipseLink JPA + Spring project, the following exception was thrown when I try to query the entity "ShippingInstruction" (No error during deployment to OC4J):

Weaving NOT Enabled
Exception [EclipseLink-127] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The get method for the attribute [consignee] does not return a ValueHolderInterface, but the mapping uses indirection.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[consignee]
Descriptor: RelationalDescriptor(jpaTest.domain.model.ShippingInstruction --> [DatabaseTable(JPA_TEST.SHIPPING_INSTRUCTION)])

Exception [EclipseLink-129] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The set method for the attribute [consignee] does not take a ValueHolderInterface as its parameter, but the mapping uses indirection.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[consignee]
Descriptor: RelationalDescriptor(jpaTest.domain.model.ShippingInstruction --> [DatabaseTable(JPA_TEST.SHIPPING_INSTRUCTION)])

Exception [EclipseLink-148] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The container policy [ListContainerPolicy(class oracle.toplink.indirection.IndirectList)] is not compatible with transparent indirection.
Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[noticeList]
Descriptor: RelationalDescriptor(jpaTest.domain.model.ShippingInstruction --> [DatabaseTable(JPA_TEST.SHIPPING_INSTRUCTION)])

Exception [EclipseLink-148] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The container policy [ListContainerPolicy(class oracle.toplink.indirection.IndirectList)] is not compatible with transparent indirection.
Mapping: org.eclipse.persistence.mappings.OneToManyMapping[remarkList]
Descriptor: RelationalDescriptor(jpaTest.domain.model.ShippingInstruction --> [DatabaseTable(JPA_TEST.SHIPPING_INSTRUCTION)])


Weaving Enabled
Exception [EclipseLink-60] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persstence.exceptions.DescriptorException
Exception Description: The method [_persistence_setconsignee_vh] or [_persistence_getconsignee_vh] is not defined in the object [jpaTest.domain.model.ShippingInstruction].
Internal Exception: java.lang.NoSuchMethodException: jpaTest.domain.model.ShippingInstrution._persistence_getconsignee_vh()
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[consignee]
Descriptor: RelationalDescriptor(jpaTest.domain.model.ShippingInstruction --> [DatabaseTble(JPA_TEST.SHIPPING_INSTRUCTION)])


Below are the mapping details defined in project.xml:
1-1 mapping
<opm:attribute-mapping xsi:type="toplink:one-to-one-mapping">
<opm:attribute-name>consignee</opm:attribute-name>
<opm:get-method>getConsigneeHolder</opm:get-method>
<opm:set-method>setConsigneeHolder</opm:set-method>
<opm:reference-class>jpaTest.domain.model.Notifyparty</opm:reference-class>
<opm:private-owned>true</opm:private-owned>
<opm:foreign-key>
<opm:field-reference>
<opm:source-field table="SHIPPING_INSTRUCTION" name="CONSIGNEE_ID" xsi:type="opm:column"/>
<opm:target-field table="NOTIFYPARTY" name="ID" xsi:type="opm:column"/>
</opm:field-reference>
</opm:foreign-key>
<opm:foreign-key-fields>
<opm:field table="SHIPPING_INSTRUCTION" name="CONSIGNEE_ID" xsi:type="opm:column"/>
</opm:foreign-key-fields>
<toplink:indirection xsi:type="toplink:value-holder-indirection-policy"/>
<toplink:selection-query xsi:type="toplink:read-object-query"/>
</opm:attribute-mapping>


1-m mapping
<opm:attribute-mapping xsi:type="toplink:one-to-many-mapping">
<opm:attribute-name>remarkList</opm:attribute-name>
<opm:get-method>getRemarkList</opm:get-method>
<opm:set-method>setRemarkList</opm:set-method>
<opm:reference-class> jpaTest.domain.model.Remark</opm:reference-class>
<opm:private-owned>true</opm:private-owned>
<opm:target-foreign-key>
<opm:field-reference>
<opm:source-field table="REMARK" name="SI_ID" xsi:type="opm:column"/>
<opm:target-field table="SHIPPING_INSTRUCTION" name="ID" xsi:type="opm:column"/>
</opm:field-reference>
</opm:target-foreign-key>
<toplink:bidirectional-target-attribute>shippingInstruction</toplink:bidirectional-target-attribute>
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>oracle.toplink.indirection.IndirectList</toplink:collection-type>
</toplink:container>
<toplink:indirection xsi:type="toplink:transparent-collection-indirection-policy"/>
<toplink:selection-query xsi:type="toplink:read-all-query">
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>oracle.toplink.indirection.IndirectList</toplink:collection-type>
</toplink:container>
</toplink:selection-query>
</opm:attribute-mapping>


m-m mapping
<opm:attribute-mapping xsi:type="toplink:many-to-many-mapping">
<opm:attribute-name>noticeList</opm:attribute-name>
<opm:get-method>getNoticeList</opm:get-method>
<opm:set-method>setNoticeList</opm:set-method>
<opm:reference-class> jpaTest.domain.model.Notice</opm:reference-class>
<opm:private-owned>true</opm:private-owned>
<opm:relation-table>CS2_DEV_EXERCISE.SI_NOTICE</opm:relation-table>
<opm:source-relation-foreign-key>
<opm:field-reference>
<opm:source-field table="SI_NOTICE" name="SI_ID" xsi:type="opm:column"/>
<opm:target-field table="SHIPPING_INSTRUCTION" name="ID" xsi:type="opm:column"/>
</opm:field-reference>
</opm:source-relation-foreign-key>
<opm:target-relation-foreign-key>
<opm:field-reference>
<opm:source-field table="SI_NOTICE" name="NOTICE_ID" xsi:type="opm:column"/>
<opm:target-field table="NOTICE" name="ID" xsi:type="opm:column"/>
</opm:field-reference>
</opm:target-relation-foreign-key>
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>oracle.toplink.indirection.IndirectList</toplink:collection-type>
</toplink:container>
<toplink:indirection xsi:type="toplink:transparent-collection-indirection-policy"/>
<toplink:selection-query xsi:type="toplink:read-all-query">
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>oracle.toplink.indirection.IndirectList</toplink:collection-type>
</toplink:container>
</toplink:selection-query>
<toplink:insert-query xsi:type="toplink:data-modify-query"/>
<toplink:delete-query xsi:type="toplink:data-modify-query"/>
<toplink:delete-all-query xsi:type="toplink:data-modify-query"/>
</opm:attribute-mapping>


Here is the get/set method defined to access consignee and its ValudHolder (generated by Toplink 10g workbench):
public Notifyparty getConsignee() {
return (Notifyparty) this.consignee.getValue();
}

public ValueHolderInterface getConsigneeHolder() {
return this.consignee;
}

public void setConsignee(Notifyparty consignee) {
this.consignee.setValue(consignee);
}

public void setConsigneeHolder(ValueHolderInterface consignee) {
this.consignee = consignee;
}


Here is the persistence.xml and applicationContext.xml:
persistence.xml
<property name="eclipselink.sessions-xml" value="sessions.xml"/>
<property name="eclipselink.session-name" value="serverSession"/>
<property name="eclipselink.weaving" value="true"/>
<property name="eclipselink.persistence-context.commit-without-persist-rules" value="true"/>
<property name="eclipselink.logging.level" value="FINEST"/>


applicationContext.xml
<context:load-time-weaver/>

<bean id="persistenceUnit" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="persistenceXmlLocations">
<list>
<value>classpath*:WEB-INF/lib/persistence.xml</value>
</list>
</property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>
<property name="defaultDataSource" ref="dataSource"/>
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter" ref="jpaAdapter"/>
<property name="persistenceUnitManager" ref="persistenceUnit"/>
</bean>

<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform" />
<property name="showSql" value="true" />
</bean>

<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />


Do I miss any configuration? Please kindly advise.

Other than trying runtime weaving, I also tried to perform compile time static weaving via EclipseLink Ant build (Link: http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28 ELUG%29#Using_EclipseLink_JPA_Weaving). However, it seems that weaving does not take place (No .class file change when checking via decompiler)... What should be the expected result after executing the static weaver? Does it support the weaving when I use sessions.xml and project.xml as JPA source?

Configuration to Static Weave JPA Entities
1) "persistenceinfo" a JAR file with following structure:
META-INF
- persistence.xml
- sessions.xml
- project.xml
2) "source" and "target" points to same location, containing the entity .class files

Thanks a lot!
(Sorry for my long post..)

[Updated on: Mon, 07 June 2010 06:48]

Report message to a moderator

Re: Problem on EclipseLink JPA Weaving using Toplink session.xml, project.xml as JPA Source [message #538256 is a reply to message #538254] Mon, 07 June 2010 06:42 Go to previous messageGo to next message
Jessie Yeung is currently offline Jessie Yeung
Messages: 8
Registered: June 2010
Junior Member
Also, from EclipseLink Spring Integration page (Link: http://wiki.eclipse.org/EclipseLink/Examples/JPA/JPASpring), there is a line:
Quote:

Spring's agent does not initialize the persistence context until the application accesses the Spring context. If the application has already triggered the loading of the persistent class before accessing the Spring context, weaving will not occur.


Does my issue related to classing loading? If yes, how can I configure to overcome the case? Please kindly advise.

Thanks a lot! Smile

[Updated on: Mon, 07 June 2010 06:42]

Report message to a moderator

Re: Problem on EclipseLink JPA Weaving using Toplink session.xml, project.xml as JPA Source [message #538482 is a reply to message #538254] Mon, 07 June 2010 17:39 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Since you have changed your code to use ValueHolderInterface, then you do not need to use weaving. Try setting weaving to false.

You may also wish to try without Spring to see if it is related to your issue.


James : Wiki : Book : Blog : Twitter
Re: Problem on EclipseLink JPA Weaving using Toplink session.xml, project.xml as JPA Source [message #538978 is a reply to message #538482] Wed, 09 June 2010 09:10 Go to previous messageGo to next message
Jessie Yeung is currently offline Jessie Yeung
Messages: 8
Registered: June 2010
Junior Member
Hi James,

Thanks for your reply.

I have tried both approach. Same exception is thrown when:
1) Weaving is set to false, and
2) Run without Spring

Exception [EclipseLink-127] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The get method for the attribute [consignee] does not return a ValueHolderInterface, but the mapping uses indirection.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[consignee]
Descriptor: RelationalDescriptor(jpaTest.domain.model.ShippingInstruction --> [DatabaseTable(JPA_TEST.SHIPPING_INSTRUCTION)])

Exception [EclipseLink-129] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The set method for the attribute [consignee] does not take a ValueHolderInterface as its parameter, but the mapping uses indirection.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[consignee]
Descriptor: RelationalDescriptor(jpaTest.domain.model.ShippingInstruction --> [DatabaseTable(JPA_TEST.SHIPPING_INSTRUCTION)])

Exception [EclipseLink-148] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The container policy [ListContainerPolicy(class oracle.toplink.indirection.IndirectList)] is not compatible with transparent indirection.
Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[noticeList]
Descriptor: RelationalDescriptor(jpaTest.domain.model.ShippingInstruction --> [DatabaseTable(JPA_TEST.SHIPPING_INSTRUCTION)])

Exception [EclipseLink-148] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The container policy [ListContainerPolicy(class oracle.toplink.indirection.IndirectList)] is not compatible with transparent indirection.
Mapping: org.eclipse.persistence.mappings.OneToManyMapping[remarkList]
Descriptor: RelationalDescriptor(jpaTest.domain.model.ShippingInstruction --> [DatabaseTable(JPA_TEST.SHIPPING_INSTRUCTION)])


But there is no problem when I run it using Toplink ORM (10g/11g)...

What should I do next to solve the issue?

Thanks a lot.
Re: Problem on EclipseLink JPA Weaving using Toplink session.xml, project.xml as JPA Source [message #539094 is a reply to message #538978] Wed, 09 June 2010 15:37 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
Hello,

This thread was cross posted here:
http://forums.oracle.com/forums/thread.jspa?threadID=1081747 &tstart=0

Have tried converting your TopLink session/project to use EclipseLink classes yet?

Best Regards,
Chris
Re: Problem on EclipseLink JPA Weaving using Toplink session.xml, project.xml as JPA Source [message #539212 is a reply to message #539094] Thu, 10 June 2010 01:36 Go to previous message
Jessie Yeung is currently offline Jessie Yeung
Messages: 8
Registered: June 2010
Junior Member
Hi Chris,

Sorry for my slow response.

I've tried to open and export the Toplink project + session.xml in EclipseLink Workbench yesterday and it works now.

It seems that I have to change all indirection-related and DB driver class from Toplink to EclipseLink to make the indirection works.

Thanks a lot! =]
Previous Topic:XML Composite Object Mapping problem
Next Topic:Invalidate Shared Cache
Goto Forum:
  


Current Time: Thu Oct 23 01:39:46 GMT 2014

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

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