Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Indirection Issue - QueryBasedValueHolder incompatible(ava.lang.ClassCastException: org.eclipse.persistence.internal.indirection.QueryBasedValueHolder incompatible with)
Indirection Issue - QueryBasedValueHolder incompatible [message #1781338] Tue, 06 February 2018 08:09 Go to next message
Somasundaram Pappannan is currently offline Somasundaram PappannanFriend
Messages: 5
Registered: October 2017
Junior Member
HI,

we are using EclipseLink 2.5.2. when try to use indirection its getting classcast exception.

Java.lang.ClassCastException: org.eclipse.persistence.internal.indirection.QueryBasedValueHolder incompatible with com.Order.

we tried Method accessing and with out Method accessing when using of Use indirection as ValueHolder.

Please give your comments.

Thanks
Som
Re: Indirection Issue - QueryBasedValueHolder incompatible [message #1781384 is a reply to message #1781338] Tue, 06 February 2018 16:01 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Show your code, but I'm guessing you are directly accessing fields within your entity from outside your entity. Weaving should replace the internals of the entity to use value holders, and if you are going to use lazy relationship, the specification states you should only access the fields outside your object via method accessors.
Re: Indirection Issue - QueryBasedValueHolder incompatible [message #1781388 is a reply to message #1781384] Tue, 06 February 2018 16:40 Go to previous messageGo to next message
Somasundaram Pappannan is currently offline Somasundaram PappannanFriend
Messages: 5
Registered: October 2017
Junior Member
Hi Chris,

Thank You for your response.

Mapping.xml entry
<attribute-mapping xsi:type="one-to-one-mapping">
<attribute-name>orderAdditionalDetailsHolder</attribute-name>
<get-method>getOrderAdditionalDetailsHolder</get-method>
<set-method>setOrderAdditionalDetailsHolder</set-method>
<reference-class>com.ford.vista.business.order.model.OrderAdditionalDetails</reference-class>
<foreign-key>
<field-reference>
<source-field table="VISTA_ORDER" name="ORDER_NO" xsi:type="column"/>
<target-field table="VISTA_ORDER_DETAILS" name="ORDER_NO" xsi:type="column"/>
</field-reference>
</foreign-key>
<selection-query xsi:type="read-object-query"/>
</attribute-mapping>

The idea is to make use of Value Holder Indirection with Method Accessing.

This is what provided in the implementation class
private PersistenceIndirection orderAdditionalDetailsHolder = PersistenceHelper.newIndirection();

public OrderAdditionalDetails getOrderAdditionalDetails() {
Object obj = orderAdditionalDetailsHolder.getValue();
return (OrderAdditionalDetails) orderAdditionalDetailsHolder.getValue();
}


public void setOrderAdditionalDetails(OrderAdditionalDetails orderAdditionalDetails) {
orderAdditionalDetailsHolder.setValue(orderAdditionalDetails);
if (orderAdditionalDetails != null) {
orderAdditionalDetails.setOrder(this);
}
}

public PersistenceIndirection getOrderAdditionalDetailsHolder() {
return orderAdditionalDetailsHolder;
}

public void setOrderAdditionalDetailsHolder(PersistenceIndirection orderAdditionalDetailsHolder) {
this.orderAdditionalDetailsHolder = orderAdditionalDetailsHolder;


This is the call in PersistenceHelper

public static PersistenceIndirection newIndirection() {

PersistenceIndirection indirection = new EclipseLinkIndirectContainer();

return indirection;
}

I have uploaded the EclipseLinkIndirectContainer class.

While we run the application we are getting the following exception
java.lang.ClassCastException: org.eclipse.persistence.internal.indirection.QueryBasedValueHolder incompatible with com.ford.vista.business.order.model.OrderAdditionalDetails
Re: Indirection Issue - QueryBasedValueHolder incompatible [message #1781409 is a reply to message #1781388] Tue, 06 February 2018 23:04 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I'm not quite sure where the error is coming from. The only part of this code that might have to do with an Order object is the orderAdditionalDetails.setOrder(this); statement, but I don't see how this is related to your error. Can you show the full stack and the code that causes it?

It also seems strange that you are implementing your own indirection objects in your object overtop of EclipseLink's own indirection objects. It makes it a bit more difficult to follow what could be happening in what seems a legacy project. Since this is likely legacy, I'd assume this was working or is working somewhere else- has something changed, and if so, what?
Re: Indirection Issue - QueryBasedValueHolder incompatible [message #1781415 is a reply to message #1781409] Wed, 07 February 2018 06:38 Go to previous messageGo to next message
Somasundaram Pappannan is currently offline Somasundaram PappannanFriend
Messages: 5
Registered: October 2017
Junior Member
Hi Chris,

Thanks for your comments.

We are using Method access and for indirection we have custom class.
It s not legacy, we are following with EclipseLink provided steps.

we have followed the below link
https://wiki.eclipse.org/Configuring_a_Mapping_(ELUG)#Configuring_ValueHolder_Indirection
Title Name:
Configuring Value Holder Indirection with Method Accessing


Please suggest are we missing any configuration settings..?


* Please fins the attached word document have the steps which we followed and StackTrace.



Thanks
Som
Re: Indirection Issue - QueryBasedValueHolder incompatible [message #1781725 is a reply to message #1781415] Mon, 12 February 2018 15:10 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
In my experience, there is very little reason to use your own value holder class implementations in pre-JPA projects so I'm curious to why you would go this route here. Also, If this is a new project, why are you not using the JPA methods overtop?

The doc you've posted says you are not using indirection, and the mapping isn't showing any indirection settings at all, but your method access is using indirection classes. If you are going to use custom value holder classes, you need additional configuration to tell EclipseLink how to build and populate them in the mapping, so I am surprised what you've shown is working. Regardless though, your error is coming from your own classes - it is your get com.ford.vista.business.order.model.Order.getOrderAdditionalDetails method line 3355 that is expecting a OrderAdditionalDetails but getting the QueryBasedValueHolder instance internally held by your value holder instance instead. You haven't fully unwrapped all your wrapper classes.
Re: Indirection Issue - QueryBasedValueHolder incompatible [message #1782619 is a reply to message #1781725] Tue, 27 February 2018 08:14 Go to previous message
Somasundaram Pappannan is currently offline Somasundaram PappannanFriend
Messages: 5
Registered: October 2017
Junior Member
Thanks lot a Chris for your updates.

I have added some more points for your reference. Please find the attached document for more understanding.

1. We are migrating from Toplink 9.0.4.5 to Eclipselink 2.5.2. This is not new project.
2. In Toplink 9.0.4.5 is working without any hassle with the same code base.
As I mentioned in the earlier post, in order.java we are using PersistenceIndirection as custom Indirection class.

The question is in Toplink how this indirection is working properly and why not in Eclispelink.


As you mentioned in the first point, Yes we are having an entry for Value holder indirection policy in mappings.xml file.

Second, you pointed that haven't fully unwrapped all your wrapper classes.


Could you please give some more details on this to resolve.

Please update are we missing any configuration ?


Thanks
Som
Previous Topic:switch off @Customizer-based filtering at runtime
Next Topic:getSingleResult return no entity even if should be return one
Goto Forum:
  


Current Time: Fri Oct 11 03:45:49 GMT 2024

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

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

Back to the top