SAP / olingo-jpa-processor-v4

The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conversion of date to Edm.Date type

mailyashgoyal opened this issue · comments

query example: http://localhost:4003/trail_db/CustomObjectUserLicenseMetrics?$filter=MetricsDate eq 2019-09-22

When converting the last segment of the query($filter=MetricsDate eq 2019-09-22), the below function is being called

EdmPrimitiveTypeKind convertToEdmSimpleType(final Class jpaType, final Attribute currentAttribute) throws ODataJPAModelException
Line number : 144
olingo-jpa-processor-v4/JPATypeConverter.java at main · SAP/olingo-jpa-processor-v4
Checks the currentAttribute if it is not null in order to convert the query parameter eg 2015-01-01 to Edm.Date

But the calling method convertToEdmSimpleType calls the
olingo-jpa-processor-v4/JPATypeConverter.java at main · SAP/olingo-jpa-processor-v4
With currentAttribute explicitly setting as null.

So the conversion to Date will not happen at all as it never succeed in the if check.
For proper conversion determineTemporalType(currentAttribute) == TemporalType.DATE
should return True, which means valid determination of TemporalType with with valid object instance.

The reason why it is being provided as null, the overridden method

EdmPrimitiveTypeKind convertToEdmSimpleType(final Class jpaType, final Attribute currentAttribute) throws ODataJPAModelException
Takes javax.persistence.metamodel.Attribute attribute
While the calling method EdmPrimitiveTypeKind convertToEdmSimpleType(final JPAAttribute attribute) throws ODataJPAModelException
has JPAAttribute

This mechanism happens only when value to type conversion check is being done.

While the check for Field to type is being propogated from IntermediateProperty.java

olingo-jpa-processor-v4/IntermediateProperty.java at main · SAP/olingo-jpa-processor-v4

Where the correct Attribute type is being set.

This issue, should also persist with Edm.Time.

The issue should be solved with version 1.1.1.
In case the problem still exists, reopen the issue