You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Ganapathi Ram <ra...@gmail.com> on 2019/12/09 08:19:21 UTC
Persistence Implementation
Hi
I am using plain JDBC to implement persistence of OData services.
I need a clarification on below code snippet from Storage.java from Deep
Insert tutorial
<https://olingo.apache.org/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html>
.
private void setLink(final Entity entity, final String
navigationPropertyName, final Entity target) {
Link link = entity.getNavigationLink(navigationPropertyName);
if (link == null) {
link = new Link();
link.setRel(Constants.NS_NAVIGATION_LINK_REL +
navigationPropertyName);
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
link.setTitle(navigationPropertyName);
link.setHref(target.getId().toASCIIString());
entity.getNavigationLinks().add(link);
}
link.setInlineEntity(target);
}
private void setLinks(final Entity entity, final String
navigationPropertyName, final Entity... targets) {
Link link = entity.getNavigationLink(navigationPropertyName);
if (link == null) {
link = new Link();
link.setRel(Constants.NS_NAVIGATION_LINK_REL +
navigationPropertyName);
link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
link.setTitle(navigationPropertyName);
link.setHref(entity.getId().toASCIIString() + "/" +
navigationPropertyName);
EntityCollection target = new EntityCollection();
target.getEntities().addAll(Arrays.asList(targets));
link.setInlineEntitySet(target);
entity.getNavigationLinks().add(link);
} else {
link.getInlineEntitySet().getEntities().addAll(Arrays.asList(targets));
}
}
Are we supposed to persist all of this data to database? I mean the Link
properties and other metadata like Rel, Title, etc. I know we are saving
Product, Category and association (as foreign key) information.
What is the best practice. Any hints on existing vendor implementations
(SAP and others) in this regard?
Thanks for your time.
--
Thanks
Ganapathi Ram
+91-98865 87488
Re: Persistence Implementation
Posted by Ramesh Reddy <ra...@redhat.com>.
You can take look at teiid.io project's OData implementation or use it for
these similar services.
Ramesh..
On Mon, Dec 9, 2019 at 2:26 AM Ganapathi Ram <ra...@gmail.com> wrote:
> Hi
>
> I am using plain JDBC to implement persistence of OData services.
>
> I need a clarification on below code snippet from Storage.java from Deep
> Insert tutorial
> <https://olingo.apache.org/doc/odata4/tutorials/deep_insert/tutorial_deep_insert.html>
> .
>
> private void setLink(final Entity entity, final String
> navigationPropertyName, final Entity target) {
> Link link = entity.getNavigationLink(navigationPropertyName);
> if (link == null) {
> link = new Link();
> link.setRel(Constants.NS_NAVIGATION_LINK_REL +
> navigationPropertyName);
> link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
> link.setTitle(navigationPropertyName);
> link.setHref(target.getId().toASCIIString());
>
> entity.getNavigationLinks().add(link);
> }
> link.setInlineEntity(target);
> }
>
> private void setLinks(final Entity entity, final String
> navigationPropertyName, final Entity... targets) {
> Link link = entity.getNavigationLink(navigationPropertyName);
> if (link == null) {
> link = new Link();
> link.setRel(Constants.NS_NAVIGATION_LINK_REL +
> navigationPropertyName);
> link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
> link.setTitle(navigationPropertyName);
> link.setHref(entity.getId().toASCIIString() + "/" +
> navigationPropertyName);
>
> EntityCollection target = new EntityCollection();
> target.getEntities().addAll(Arrays.asList(targets));
> link.setInlineEntitySet(target);
>
> entity.getNavigationLinks().add(link);
> } else {
>
> link.getInlineEntitySet().getEntities().addAll(Arrays.asList(targets));
> }
> }
>
> Are we supposed to persist all of this data to database? I mean the Link
> properties and other metadata like Rel, Title, etc. I know we are saving
> Product, Category and association (as foreign key) information.
>
> What is the best practice. Any hints on existing vendor implementations
> (SAP and others) in this regard?
>
> Thanks for your time.
>
> --
> Thanks
> Ganapathi Ram
> +91-98865 87488
>