tapvanvn / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

Cannot apply filter with one member of composite key #169

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run odata4j-examples project from source package of odata4j, choose 
NorthwindJpaProducerExample
2. Enter uri 
http://localhost:8886/NortwindJpaProducerExample.svc/Order_Details?$filter=Order
ID eq 10248
3. Observe error returned: unknown state or association field [OrderID] of 
class [org.odata4j.examples.producer.jpa.northwind.Order_Details]

What is the expected output? What do you see instead?
The same filter works here, on the wcf version of Northwind.svc:
http://services.odata.org/Northwind/Northwind.svc/Order_Details?$filter=OrderID 
eq 10248

What version of the product are you using? On what operating system?
0.7, Windows7, but it happened for odata4j 0.5, 0.6, as well.

Please provide any additional information below.
I had noticed this error in one of my custom odata4j services, so it's not only 
for the Northwind service alone.
If there is a workaround for this, please let me know...most of the times, a 
composite key query is accessible through the "one" table from a one-to-many 
relationship. There are cases, though, where the second parameter of the 
composite key is non-important (max version of a version id, for example), and 
we just want to query by the relevant member of the composite key.
I tried a work around to add setter and getter in the entity class for the one 
member from the PK that I wanted to query by, and that worked for the GET and 
MERGE (select, edit). The PUT (insert) failed because of the same key being 
mentioned multiple times in the SQL insert statement generated by jpql.

Thank you,
Serban

Original issue reported on code.google.com by serbanva...@gmail.com on 30 Apr 2012 at 7:27

GoogleCodeExporter commented 9 years ago
I found another issue which mentions that a query against the primary key can 
be written as follows...
http://localhost:8886/JPAProducerExample.svc/Order_Details?$format=json&$filter=
orderDetailsPK/ProductID%20lt%2011
If this works, then I don't consider the above to be a major issue. The issue 
still remains since I don't think the PK name is mentioned in the $metadata, 
and that basically means that the PK name is unknown for the external user.

Original comment by serbanva...@gmail.com on 30 Apr 2012 at 11:46