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.
Apache License 2.0
123 stars 76 forks source link

Problem when use UUID in $filter #136

Closed AntonIV8 closed 2 years ago

AntonIV8 commented 3 years ago

Hello. I have problem, when try run GET request with

$filter=SomeUUIDField eq 53513849-4d3c-4060-9231-2f83dfa14bda

Response

"error": { "code": null, "message": "java.util.UUID.(java.lang.String)" }

This is how I describe model field:

@Converter(converterClass = UUIDConverter.class, name = "SomeUUIDField") @Convert("SomeUUIDField") @Column(name = "SomeUUIDField", length = 36, unique = true, nullable = false) private UUID SomeUUIDField;

Converter class from tutorials:

public class UUIDConverter implements org.eclipse.persistence.mappings.converters.Converter {
private static final long serialVersionUID = 1L;

Override
public UUID convertObjectValueToDataValue(Object objectValue, Session session) {
    return (UUID) objectValue;
}

@Override
public UUID convertDataValueToObjectValue(Object dataValue, Session session) {
    return (UUID) dataValue;
}

@Override
public boolean isMutable() {
    return false;
}

@Override
public void initialize(DatabaseMapping mapping, Session session) {
    DatabaseField field = mapping.getField();
    field.setSqlType(Types.LONGNVARCHAR);
    field.setTypeName("java.util.UUID");
    field.setColumnDefinition("UUID");
}
}
wog48 commented 2 years ago

Hello,

I had a look at the issue. The solution is part of https://github.com/SAP/olingo-jpa-processor-v4/pull/137. Pleas have a look at JPALiteralOperator adoption

wog48 commented 2 years ago

Hello,

the fix is part of version 0.3.10. In case the problem still exist, re-open the issue.