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.
import java.util.UUID;
import javax.persistence.*;
@Entity
public class Entity
{
@Id
@Column(name = "guid", length = 36)
@Convert(converter = UuidConverter.class)
private UUID id = UUID.randomUUID();
}
import java.util.UUID;
import javax.persistence.*;
@Converter
public class UuidConverter implements AttributeConverter<UUID, String>
{
@Override
public String convertToDatabaseColumn(UUID attribute)
{
return attribute.toString();
}
@Override
public UUID convertToEntityAttribute(String dbData)
{
return UUID.fromString(dbData);
}
}
✔️ Setup is working with the in-memory H2 database.
❌ Setup is not working when using MariaDB (org.mariadb.jdbc.Driver) as datasource.
However, after debugging a couple of hours through the code base, my main question is:
Why is the defined UuidConverter not respected, when building the SQL query criteria?
UuidConverter not respected due to conversionRequired == false for all olingo supported types (including java.util.UUID)
Related request URL examples:
Related JPA Setup
✔️ Setup is working with the in-memory H2 database. ❌ Setup is not working when using MariaDB (org.mariadb.jdbc.Driver) as datasource.
However, after debugging a couple of hours through the code base, my main question is: Why is the defined
UuidConverter
not respected, when building the SQL query criteria?UuidConverter
not respected due toconversionRequired == false
for all olingo supported types (includingjava.util.UUID
)Since the SQL statement is native, I guess it needs database type related query arguments.
converter = Optional.ofNullable(jpaPath.get().getLeaf().getConverter());
might be:converter = Optional.ofNullable(jpaPath.get().getLeaf().getRawConverter());
Regards