[ 
https://issues.apache.org/jira/browse/OLINGO-604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chandan V.A resolved OLINGO-604.
--------------------------------
    Resolution: Fixed

> Injected Entity Managers are closed after fetching query results
> ----------------------------------------------------------------
>
>                 Key: OLINGO-604
>                 URL: https://issues.apache.org/jira/browse/OLINGO-604
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.4
>            Reporter: Chandan V.A
>            Assignee: Chandan V.A
>            Priority: Minor
>
> There is an issue with the way the result list is accessed in JPAProcessor 
> method: private Object readEntity(final Object uriParserResultView, final 
> JPQLContextType contextType)
> Currently (Olingo 2.03) accesses the Resultlist by following code snippet:
> …
> query = em.createQuery(selectJPQLStatement.toString());
>         if (!query.getResultList().isEmpty()) {
>           selectedObject = query.getResultList().get(0);
> …
> Because an injected entityprocessor (via proxy) from the Spring Framework, on 
> the first access to query.getResultList() closes the entitymanager after the 
> query transaction is done.
> Since the object is accessed in a separate call the entitymanager is closed 
> and therefore we get an error “Attempting to execute an operation on a closed 
> EntityManager."
> The solution is ..
> By assigning the ResultList to a List, the issue is solved:
> …
> query = em.createQuery(selectJPQLStatement.toString());
>                 final List resultList = query.getResultList();
>                 if (!resultList.isEmpty())
>                 {
>                     selectedObject = resultList.get(0);
>                 }
> …



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to