olingo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wesley Rosa <wesley.r...@itsgroup.com.br>
Subject Olingo JPA: Problem reading an entity with composite String typed primary key.
Date Wed, 02 May 2018 17:55:24 GMT
Good evening,

 

I have a Java Application running on a Tomcat 8 Server, with JPA v. 2.1 and
Hibernate 5.2.5.

I'm using Apache Olingo JPA v. 2.0.10.

 

I have an OData entity model whose service metadata document description is
as follows: 

 

<Key>

<PropertyRef Name="BusinessSectorId"/>

<PropertyRef Name="DistributionCenterId"/>

<PropertyRef Name="PartnerId"/>

<PropertyRef Name="SalesOrganizationId"/>

</Key>

<Property Name="BusinessSectorId" Type="Edm.String" Nullable="false"/>

<Property Name="Cpf" Type="Edm.String" Nullable="false" MaxLength="11"/>

<Property Name="DistributionCenterId" Type="Edm.String" Nullable="false"/>

<Property Name="Email" Type="Edm.String" Nullable="true" MaxLength="241"/>

<Property Name="FieldAux1" Type="Edm.String" Nullable="true"
MaxLength="100"/>

<Property Name="FieldAux2" Type="Edm.String" Nullable="true"
MaxLength="50"/>

<Property Name="FieldAux3" Type="Edm.String" Nullable="true"
MaxLength="10"/>

<Property Name="FieldAux5" Type="Edm.String" Nullable="true" MaxLength="2"/>

<Property Name="Name" Type="Edm.String" Nullable="false" MaxLength="35"/>

<Property Name="PartnerId" Type="Edm.Int64" Nullable="false"/>

<Property Name="Phone" Type="Edm.String" Nullable="true" MaxLength="16"/>

<Property Name="SalesOrganizationId" Type="Edm.String" Nullable="false"/>

<Property Name="Type" Type="Edm.String" Nullable="true" MaxLength="5"/>

</EntityType>

 

In a create operation, the String primary Keys (BusinessSectorId,
DistributionCenterId, SalesOrganizationId) have to be included manually, but
the PartnerId key is generated automatically.

 

So, essentially, I have a entity with four primary Keys (three of them are
of type String and one of type Long). I can successfully create a Partner
entity, but when I try to read/update/delete the recently created Partner,
it fails, returning me a 404 status code  with a "Requested entity could not
be found" message.


There is an exception to this case though: when the String primary Keys have
the same value (e.g.: "BusinessSectorId='02'","DistributionCenterId='02'"
and "SalesOrganizationId='02'"), the read/update/delete operations work as
expected. 

 

Below there are some test scenarios which illustrate the problem. Assume
that the entities that I'm trying to read already exist in my DB.

 

Test Scenario 1: Different values in those 3 keys. Server Returns HTTP 404.

 

Request URL:

 

http://localhost:8080/sfa-mvp/api/Partners(BusinessSectorId='4',Distribution
CenterId='41',PartnerId=1000000000L,SalesOrganizationId='0101')

 

Server Response Body:

 

<error
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<code/>

<message xml:lang="en-US">Requested entity could not be found.</message>

</error>

 

Test Scenario 2: Equals values in those 3 keys. Server Returns HTTP 200 with
the requested Entity in the Response Body.

 

Request URL:

 

http://localhost:8080/sfa-mvp/api/Partners(BusinessSectorId='09',Distributio
nCenterId='09',PartnerId=1000000001L,SalesOrganizationId='09')

 

Server Response Body:

 

<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"xml:base="htt
p://localhost:8080/sfa-mvp/api/">

<id>

http://localhost:8080/sfa-mvp/api/Partners(BusinessSectorId='09',Distributio
nCenterId='09',PartnerId=1000000001L,SalesOrganizationId='09')

</id>

<title type="text">Partners</title>

<updated>2018-05-02T14:00:59.366-03:00</updated>

<category term="sfa.Partner"
scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

<link
href="Partners(BusinessSectorId='09',DistributionCenterId='09',PartnerId=100
0000001L,SalesOrganizationId='09')" rel="edit" title="Partner"/>

<content type="application/xml">

<m:properties>

<d:BusinessSectorId>09</d:BusinessSectorId>

<d:Cpf>12345673</d:Cpf>

<d:DistributionCenterId>09</d:DistributionCenterId>

<d:Email m:null="true"/>

<d:FieldAux1 m:null="true"/>

<d:FieldAux2 m:null="true"/>

<d:FieldAux3 m:null="true"/>

<d:FieldAux5 m:null="true"/>

<d:Name>Wesley3</d:Name>

<d:PartnerId>1000000001</d:PartnerId>

<d:Phone m:null="true"/>

<d:SalesOrganizationId>09</d:SalesOrganizationId>

<d:Type>ZKR4</d:Type>

</m:properties>

</content>

</entry>

 

This problem has completely stopped my development team and we have an
important deadline coming that depends on this feature working properly, so
an answer to this would be greatly appreciated.

 

With regards, Wesley.

 

 


http://www.itsgroup.com.br/assinaturadeemail/Logo_ITS_2.png


 

Wesley Rosa


 

Java Developer
+55 51 99882-3675 | +55 51 3206-1714
wesley.rosa@itsgroup.com.br



 


http://www.itsgroup.com.br/assinaturadeemail/SAPGoldPartner.png

 <http://www.itsgroup.com.br/> www.itsgroup.com.br
 <https://www.facebook.com/itsgrouprs/> Facebook |
<https://www.linkedin.com/company/its-group> LinkedIn

 

 


Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message