Problem on EclipseLink JPA Weaving using Toplink session.xml, project.xml as JPA Source [message #538254] |
Mon, 07 June 2010 06:39 |
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
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04193 seconds