Hi,
On 11/12/13 15:54, Jim Talbut wrote:
Hi Sergey,
I've been using OpenJPA, but I don't mind it not working with interfaces
as long as it is documented.
Anyone using interfaces can do what I did, which is to have:
public interface OrderLine
{
Product getOrderLineItem();
void setOrderLineItem( Product orderLineItem );
}
@Entity
public class OrderLine_JpaImpl implements OrderLine, Serializable {
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "prdId", nullable = false)
@ForeignKey
@Index
private Product_JpaImpl orderLineItem;
@Override
public Product_JpaImpl getOrderLineItem() {
return orderLineItem;
}
@Override
public void setOrderLineItem(Product orderLineItem) {
setOrderLineItem((Product_JpaImpl)orderLineItem);
}
public void setOrderLineItem(Product_JpaImpl orderLineItem) {
this.orderLineItem = orderLineItem;
}
}
I didn't know that Java permitted a sub class to return a sub class from
an override (i.e. the way getOrderLineItem is considered an override
despite returning a more specific type).
This way the getter always returns the Entity type, and we have a hidden
setter that accepts the correct type.
I reckon that having your generic code be unable to know that it can use
setOrderLineItem(Product orderLineItem) is a reasonable limitation.
I think the problem I'm left with is caused by trying to specify
properties of a child of a list, rather than being related to the
interfaces.
Thanks for the info above, I haven't setup a JPA2 test, but I did a
trivial fix to get interface properties supported as it may be needed
even without JPA2. Please test it after we get CXF-5449 done
Cheers, Sergey
Jim
On 11/12/2013 13:14, Sergey Beryozkin wrote:
Hi Jim
Thanks; by the way I can't setup a test where an entity returns an
interface. Apparently not all JPA2 implementations support it.
We can do a basic interface proxy to get a template working with
interfaces, but I will need some help with configuring persistence.xml
and adding a test dependency to pom.xml,
so, can you do it please, update persistence.xml in
rt/rs/extensions/search and pom.xml and send the diff to me or open a
JIRA (Support for testing another JPA2 implementation) ?
Thanks, Sergey
On 09/12/13 20:40, Jim Talbut wrote:
On 09/12/2013 13:28, Sergey Beryozkin wrote:
org.apache.cxf.jaxrs.ext.search.jpa.JPATypedVisitorTest has few tests
where collections of primitive and complex types are used.
Can you please open a JIRA and prototype the way the beans are
linked to
each other (please narrow it down to the faulty path only), somehow the
parser has got confused, needs to be fixed
Thanks, Sergey
Thanks Sergey.
Created https://issues.apache.org/jira/browse/CXF-5449, mainly as a copy
of this email.
I /think/ the failure occurs when you have:
1. A parent entity containing a list of children.
2. The children entities contain a single grandchild.
3. The search is for a property of the grandchild.
And it fails when it tries to set the grandchild in the child.
I've actually got another layer in the hierarchy (great-grandchild), but
given where the exception comes from I suspect that isn't needed to
cause the failure.
Jim