[
https://issues.apache.org/jira/browse/OLINGO-1044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16734833#comment-16734833
]
Peter Markus de Vries commented on OLINGO-1044:
-----------------------------------------------
This bug still exists in olingo 4.5.0, I'm experiencing the same issue and am
too using some POJOs generated with the maven plugin.
Calling the flush method on the container yields a NullPointerException, like
Athish already reported.
Since this issue has been reported over 2 years ago, how are the chances it
will ever get fixed?
> Trying to Add and Flush
> -----------------------
>
> Key: OLINGO-1044
> URL: https://issues.apache.org/jira/browse/OLINGO-1044
> Project: Olingo
> Issue Type: Bug
> Components: odata4-client
> Affects Versions: (Java) V4 4.3.0
> Reporter: Athish
> Priority: Critical
>
> Service.java & System.java generated from olingo maven plugin from the CRM
> 2016 $Metadata
> Trying to create ODataClient
> Service<EdmEnabledODataClient> service = Service
> .getV4("https://example.crm2016/api/data/v8.1");
> odata.test.pojo.microsoft.dynamics.crm.System container =
> service.getEntityContainer(odata.test.pojo.microsoft.dynamics.crm.System.class);
> Trying to preform CRUD operation
> 1.Retrial from the Container is working fine
> for (Contact c : container.getContacts())
> System.out.printf("Firstname: %s - Fullname: %s%n",
> c.getFirstname(), c.getLastname());
> 2. When trying to Create by Adding and Flush getting Null Pointer Exception
> final Contact order = container.newEntityInstance(Contact.class);
> order.setFirstname("try with flush");
> container.getContacts().add(order);
> container.flush();
> Exception in thread "main" java.lang.NullPointerException
> at
> org.apache.olingo.ext.proxy.utils.CoreUtils.getODataEntityProperty(CoreUtils.java:153)
> at
> org.apache.olingo.ext.proxy.utils.CoreUtils.addProperties(CoreUtils.java:294)
> at
> org.apache.olingo.ext.proxy.commons.AbstractPersistenceManager.processEntityContext(AbstractPersistenceManager.java:157)
> at
> org.apache.olingo.ext.proxy.commons.AbstractPersistenceManager.flush(AbstractPersistenceManager.java:99)
> at
> org.apache.olingo.ext.proxy.commons.TransactionalPersistenceManagerImpl.flush(TransactionalPersistenceManagerImpl.java:49)
> at
> org.apache.olingo.ext.proxy.commons.EntityContainerInvocationHandler.invoke(EntityContainerInvocationHandler.java:86)
> at com.sun.proxy.$Proxy3.flush(Unknown Source)
> at com.test.olingo.pojo.PojoExample.insert(PojoExample.java:72)
> at com.test.olingo.pojo.PojoExample.main(PojoExample.java:54)
> client.getCachedEdm().getEntityType(entity) is returing null
> ----------------------------------------------------------------------------------------
> PojoExample.java
> package com.test.olingo.pojo;
> import odata.test.pojo.Service;
> import odata.test.pojo.microsoft.dynamics.crm.types.Contact;
> import org.apache.olingo.client.api.EdmEnabledODataClient;
> import org.apache.olingo.client.core.http.NTLMAuthHttpClientFactory;
> public class PojoExample {
> public static void main(String args[]) {
> String serviceRoot = "https://example.crm2016/api/data/v8.1";
> String workstation = "***";
> String username = "***";
> String password = "***";
> String domain = "****";
> // Client HTTP Client factory for active directory
> NTLMAuthHttpClientFactory factory = new
> NTLMAuthHttpClientFactory(
> username, password, workstation, domain);
> // Load the odata client with the HTTP client factory
> // Get the service and set the client
> Service<EdmEnabledODataClient> service = Service
> .getV4(serviceRoot);
> EdmEnabledODataClient client = service.getClient();
> client.getConfiguration().setHttpClientFactory(factory);
>
>
> odata.test.pojo.microsoft.dynamics.crm.System container =
> service
>
> .getEntityContainer(odata.test.pojo.microsoft.dynamics.crm.System.class);
>
> retrive(container);
> create(container);
> }
> private static void retrive(
> odata.test.pojo.microsoft.dynamics.crm.System
> container) {
> for (Contact c : container.getContacts())
> System.out.printf("Firstname: %s - Fullname: %s%n",
> c.getFirstname(), c.getLastname());
> }
> private static void create(
> odata.test.pojo.microsoft.dynamics.crm.System
> container) {
> final Contact order =
> container.newEntityInstance(Contact.class);
> order.setFirstname("try with flush");
> container.getContacts().add(order);
> container.flush();
> System.out.println("inserted");
> }
>
> }
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)