Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,17 @@ private static String evaluateComparingExpression(String uriLiteral, final EdmSi
(Calendar) edmSimpleType.valueOfString(uriLiteral, EdmLiteralKind.DEFAULT, null, edmSimpleType
.getDefaultType());

Object realDateTime = datetime;
if (edmMappedType != null && datetime != null) {
String edmMappedTypeName = edmMappedType.getName();
ODataJavaTimeCallback callback = ODataJPAContextImpl.getContextInThreadLocal().getServiceFactory().getCallback(ODataJavaTimeCallback.class);
if (callback != null) {
realDateTime = callback.convert(datetime, edmMappedTypeName);
}
}

if (!positionalParameters.containsKey(index)) {
positionalParameters.put(index, datetime);
positionalParameters.put(index, realDateTime);
}
uriLiteral = "?" + index;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.apache.olingo.odata2.jpa.processor.core;

import org.apache.olingo.odata2.api.ODataCallback;

import java.util.Calendar;

/**
* Created by marcinpiela on 05/10/2024.
*/
public interface ODataJavaTimeCallback extends ODataCallback {
Object convert(Calendar calendar, String javaTimeType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
import java.util.List;
import java.util.Map;

import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
import org.apache.olingo.odata2.api.edm.EdmException;
import org.apache.olingo.odata2.api.edm.EdmMapping;
Expand Down Expand Up @@ -242,7 +245,10 @@ public static Object getPropertyValue(final Method method, final Object entity,
method.setAccessible(true);
Class<?> returnType = method.getReturnType();

if (returnType.equals(char[].class)) {
if(method.isAnnotationPresent(XmlJavaTypeAdapter.class)) {
XmlAdapter xmlAdapter = method.getAnnotation(XmlJavaTypeAdapter.class).value().newInstance();
propertyValue = xmlAdapter.marshal(method.invoke(entity));
} else if (returnType.equals(char[].class)) {
char[] ch = (char[]) method.invoke(entity);
if (ch != null) {
propertyValue = (String) String.valueOf((char[]) method.invoke(entity));
Expand Down Expand Up @@ -270,13 +276,7 @@ public static Object getPropertyValue(final Method method, final Object entity,
propertyValue = method.invoke(entity);
}
}
} catch (IllegalAccessException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
} catch (IllegalArgumentException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
} catch (InvocationTargetException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
} catch (SecurityException e) {
} catch (Exception e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}

Expand Down