You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Bernd Speckmann <bs...@hotmail.com> on 2016/01/15 09:34:25 UTC
Olingo Post foreign key attribute problem
Hi all,I've followed the tutorial posted here: http://scn.sap.com/community/gateway/blog/2014/02/05/odata-producer-using-apache-olingo-with-mysql-jpa-tomcat-web-serverInstead of olingo 1.0.0 I'm using the current v2. Everything seems to be ok.But now I have one problem: I want to create a new entity object which has one foreign key (relationship). This is not working.I have the following code:...//bi-directional many-to-one association to EvtOrt@ManyToOne@JoinColumn(name="FK_ORT")private EvtOrt evtOrt;...When I call the URL http://localhost:8080/event2/event2.svc/EvtEvents with this body in POST message (using Postman in chrome) it always inserts NULL instead of value 1:{ "d": { "Anzplaetze": 3, "Beschreibung": "Dies ist eine Testveranstaltung. In ihr geht es um Tests...", "Bild": null, "DatumBis": null, "DatumVon": null, "Eventid": 2, "EvtOrt": 1, "Name": "Testveranstaltung3", "Verfplaetze": 0 }}Anybody can help me with this issue?Thanks ahead
RE: Olingo Post foreign key attribute problem
Posted by "V.A, Chandan" <ch...@sap.com>.
Hello Bernd,
Following is an example where ToEvtOrts is a navigation property defined in entity EvtEvents.
With the below example an entity of type EvtEvents is created and linked with EvtOrts.
{
"__metadata": { "uri": "EvtEvents(123)" },
...
...
...
"ToEvtOrts": { "__metadata": {"uri": "EvtOrts(1)"}
}
Thanks
Kind Regards
Chandan
From: Bernd Speckmann [mailto:bsschrott@hotmail.com]
Sent: Friday, January 15, 2016 5:32 PM
To: user@olingo.apache.org
Subject: RE: Olingo Post foreign key attribute problem
Hello,
thank you.
Is it possible to help me with my json post (see below)?
"EvtOrt" is the other entity which I want to refer. In table "EvtOrt" an entry with ID "1" already exists, so I don't think I need a deep insert. Correct?
I can view the entityset with http://localhost:8080/event2/event2.svc/EvtEvents
Thank you and kind regards,
Bernd
________________________________
From: chandan.v.a@sap.com<ma...@sap.com>
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: RE: Olingo Post foreign key attribute problem
Date: Fri, 15 Jan 2016 11:18:53 +0000
Hello Bernd,
To link two entities you need to use Inline Links in case parent entity already exisits (refer section 2.4 in http://www.odata.org/documentation/odata-version-2-0/operations/) or deep insert in case if both the entities don't exist.
Passing values to Foreign keys in entity body is not supported by OData JPA processor.
Thanks
Kind Regards
Chandan
From: Bernd Speckmann [mailto:bsschrott@hotmail.com]
Sent: Friday, January 15, 2016 2:04 PM
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Olingo Post foreign key attribute problem
Hi all,
I've followed the tutorial posted here: http://scn.sap.com/community/gateway/blog/2014/02/05/odata-producer-using-apache-olingo-with-mysql-jpa-tomcat-web-server
Instead of olingo 1.0.0 I'm using the current v2. Everything seems to be ok.
But now I have one problem:
I want to create a new entity object which has one foreign key (relationship). This is not working.
I have the following code:
...
//bi-directional many-to-one association to EvtOrt
@ManyToOne
@JoinColumn(name="FK_ORT")
private EvtOrt evtOrt;
...
When I call the URL http://localhost:8080/event2/event2.svc/EvtEvents with this body in POST message (using Postman in chrome) it always inserts NULL instead of value 1:
{
"d": {
"Anzplaetze": 3,
"Beschreibung": "Dies ist eine Testveranstaltung. In ihr geht es um Tests...",
"Bild": null,
"DatumBis": null,
"DatumVon": null,
"Eventid": 2,
"EvtOrt": 1,
"Name": "Testveranstaltung3",
"Verfplaetze": 0
}
}
Anybody can help me with this issue?
Thanks ahead
RE: Olingo Post foreign key attribute problem
Posted by Bernd Speckmann <bs...@hotmail.com>.
Hello,thank you. Is it possible to help me with my json post (see below)?
"EvtOrt" is the other entity which I want to refer. In table "EvtOrt" an entry with ID "1" already exists, so I don't think I need a deep insert. Correct? I can view the entityset with http://localhost:8080/event2/event2.svc/EvtEvents
Thank you and kind regards,Bernd
From: chandan.v.a@sap.com
To: user@olingo.apache.org
Subject: RE: Olingo Post foreign key attribute problem
Date: Fri, 15 Jan 2016 11:18:53 +0000
Hello Bernd,
To link two entities you need to use Inline Links in case parent entity already exisits (refer section 2.4 in
http://www.odata.org/documentation/odata-version-2-0/operations/) or deep insert in case if both the entities don’t exist.
Passing values to Foreign keys in entity body is not supported by OData JPA processor.
Thanks
Kind Regards
Chandan
From: Bernd Speckmann [mailto:bsschrott@hotmail.com]
Sent: Friday, January 15, 2016 2:04 PM
To: user@olingo.apache.org
Subject: Olingo Post foreign key attribute problem
Hi all,
I've followed the tutorial posted here: http://scn.sap.com/community/gateway/blog/2014/02/05/odata-producer-using-apache-olingo-with-mysql-jpa-tomcat-web-server
Instead of olingo 1.0.0 I'm using the current v2. Everything seems to be ok.
But now I have one problem:
I want to create a new entity object which has one foreign key (relationship). This is not working.
I have the following code:
...
//bi-directional many-to-one association to EvtOrt
@ManyToOne
@JoinColumn(name="FK_ORT")
private EvtOrt evtOrt;
...
When I call the URL http://localhost:8080/event2/event2.svc/EvtEvents with this body in POST message (using Postman in chrome)
it always inserts NULL instead of value 1:
{
"d": {
"Anzplaetze": 3,
"Beschreibung": "Dies ist eine Testveranstaltung. In ihr geht es um Tests...",
"Bild": null,
"DatumBis": null,
"DatumVon": null,
"Eventid": 2,
"EvtOrt": 1,
"Name": "Testveranstaltung3",
"Verfplaetze": 0
}
}
Anybody can help me with this issue?
Thanks ahead
RE: Olingo Post foreign key attribute problem
Posted by "V.A, Chandan" <ch...@sap.com>.
Hello Bernd,
To link two entities you need to use Inline Links in case parent entity already exisits (refer section 2.4 in http://www.odata.org/documentation/odata-version-2-0/operations/) or deep insert in case if both the entities don't exist.
Passing values to Foreign keys in entity body is not supported by OData JPA processor.
Thanks
Kind Regards
Chandan
From: Bernd Speckmann [mailto:bsschrott@hotmail.com]
Sent: Friday, January 15, 2016 2:04 PM
To: user@olingo.apache.org
Subject: Olingo Post foreign key attribute problem
Hi all,
I've followed the tutorial posted here: http://scn.sap.com/community/gateway/blog/2014/02/05/odata-producer-using-apache-olingo-with-mysql-jpa-tomcat-web-server
Instead of olingo 1.0.0 I'm using the current v2. Everything seems to be ok.
But now I have one problem:
I want to create a new entity object which has one foreign key (relationship). This is not working.
I have the following code:
...
//bi-directional many-to-one association to EvtOrt
@ManyToOne
@JoinColumn(name="FK_ORT")
private EvtOrt evtOrt;
...
When I call the URL http://localhost:8080/event2/event2.svc/EvtEvents with this body in POST message (using Postman in chrome) it always inserts NULL instead of value 1:
{
"d": {
"Anzplaetze": 3,
"Beschreibung": "Dies ist eine Testveranstaltung. In ihr geht es um Tests...",
"Bild": null,
"DatumBis": null,
"DatumVon": null,
"Eventid": 2,
"EvtOrt": 1,
"Name": "Testveranstaltung3",
"Verfplaetze": 0
}
}
Anybody can help me with this issue?
Thanks ahead