You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2013/11/01 17:41:17 UTC

[jira] [Commented] (OLINGO-55) Enable JPA Processor to throw detail errors

    [ https://issues.apache.org/jira/browse/OLINGO-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13811423#comment-13811423 ] 

ASF subversion and git services commented on OLINGO-55:
-------------------------------------------------------

Commit ae8f883d49c2d5826f10ecf53f658c72875e6893 in branch refs/heads/master from [~chandan.v.a]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=ae8f883 ]

[OLINGO-55] - Enable JPA Processor Library to throw detail Errors.

An instance of type ODataJPAErrorCallback is registered when
setDetailErrors(true) is invoked from the service factory. This enables
detail errors to be thrown as inner messages in OData Error response.


Signed-off-by: Chandan V A <ch...@sap.com>

> Enable JPA Processor to throw detail errors
> -------------------------------------------
>
>                 Key: OLINGO-55
>                 URL: https://issues.apache.org/jira/browse/OLINGO-55
>             Project: Olingo
>          Issue Type: Sub-task
>          Components: odata2-jpa
>    Affects Versions: 1.1.0
>            Reporter: Chandan V.A
>            Assignee: Chandan V.A
>             Fix For: 1.1.0
>
>
> OData2 JPA Processor throws non detail error messages like 
> "OData - JPA Runtime: JPA create request is not correct"
> To know the real cause for such errors ODataErrorCallBack interface needs to be implemented by respective service factory implementation. To enable quick start to the service development and considering minimal coding to enable JPA models as OData services;  A default error call back implementation for OData2 JPA Processor library will be implemented. The call back can be registered by calling the protected method setDetailErrors(true). The method is part of ODataJPAServiceFactory class.
> An Example Service Factory Implementation
> public class JPAReferenceServiceFactory extends ODataJPAServiceFactory {
>   private static final String PUNIT_NAME = "salesorderprocessing";
>   private static final String MAPPING_MODEL = "SalesOrderProcessingMappingModel.xml";
>   private static final String CONFIG = "Configuration";
>   private static final String SHOW_DETAIL_ERROR = "showdetailerror";
>   @Override
>   public ODataJPAContext initializeODataJPAContext()
>       throws ODataJPARuntimeException {
>     ODataJPAContext oDataJPAContext = getODataJPAContext();
>     oDataJPAContext.setEntityManagerFactory(JPAEntityManagerFactory.getEntityManagerFactory(PUNIT_NAME));
>     oDataJPAContext.setPersistenceUnitName(PUNIT_NAME);
>     oDataJPAContext.setJPAEdmMappingModel(MAPPING_MODEL);
>     oDataJPAContext
>         .setJPAEdmExtension((JPAEdmExtension) new SalesOrderProcessingExtension());
>     setErrorLevel(); // Based on parameters from Configuration file set the error level to detail or no detail
>     return oDataJPAContext;
>   }
>   private void setErrorLevel() {
>     ResourceBundle config = ResourceBundle.getBundle(CONFIG);
>     boolean error = Boolean.parseBoolean((String) config.getObject(SHOW_DETAIL_ERROR));
>     setDetailErrors(error);
>   }
> }
> If error level is set to detail, following is the format for the Error (Example based on Eclipselink)
> {
> error: {
> code: null
> message: {
> lang: "en"
> value: ""OData - JPA Runtime: JPA create request is not correct""
> }-
> innererror: "class javax.persistence.RollbackException : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Violation of unique constraint SYS_PK_47: duplicate value(s) for column(s) SO_ID in statement [INSERT INTO T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CREATIONDATE, CURRENCY_CODE, DELIVERY_STATUS, GROSSAMOUNT, LONG_TEXT, NETAMOUNT, SHORT_TEXT, STATUS, CITY, COUNTRY, HOUSE_NUMBER, STREET_NAME) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)] Error Code: -104 Call: INSERT INTO T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CREATIONDATE, CURRENCY_CODE, DELIVERY_STATUS, GROSSAMOUNT, LONG_TEXT, NETAMOUNT, SHORT_TEXT, STATUS, CITY, COUNTRY, HOUSE_NUMBER, STREET_NAME) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) bind => [2, 2, null, null, null, null, 0.0, null, 0.0, null, null, Chennai, null, 0, null] Query: InsertObjectQuery(org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderHeader@59729bd9)"
> }-
> }



--
This message was sent by Atlassian JIRA
(v6.1#6144)