[
https://issues.apache.org/jira/browse/OLINGO-55?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Christian Amend closed OLINGO-55.
---------------------------------
Release is build.
> 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: V2 1.1.0
> Reporter: Chandan V.A
> Assignee: Chandan V.A
> Fix For: V2 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.5#6160)