Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
V2 1.1.0
-
None
Description
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
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)"
}-
}
Attachments
Issue Links
- Blocked
-
OLINGO-1364 Exception when calling Function Import for JPA Model
- Resolved