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
122 stars 78 forks source link

AttributeConverter is not applying while reading data #223

Closed sahashmi closed 1 year ago

sahashmi commented 1 year ago

I have Odata4 service based on this tech stack:

Spring Boot 2.7.14 Java 8 Apache Olingo 4.9.0 SAP JPA Processor 1.0.9 Eclipselink 2.7.13 PostgreSQL

In my Entity class I have GeospatialCollection mapped to geometry Postgresql column like,

@Column(name = "geography")
@EdmGeospatial(dimension = Geospatial.Dimension.GEOMETRY, srid = "27700")
private GeospatialCollection geography;

I also have AttributeConverter that converts Geospatial type to PGobject and vice versa, converter definition is.

@Converter(autoApply = true) public class GeospatialConverterToRead implements AttributeConverter<GeospatialCollection, PGobject> {

@Override
public PGobject convertToDatabaseColumn(GeospatialCollection geospatials) {
    //PGobject pGobject = new PGobject();
    //return pGobject;
}

@Override
public GeospatialCollection convertToEntityAttribute(PGobject pGobject) {
    //List<Geospatial> geospatialList = new ArrayList<>();
    //GeospatialCollection  geospatialCollection = new GeospatialCollection(Geospatial.Dimension.GEOMETRY, null, geospatialList);
    //return geospatialCollection;
}

}

This converter is working for POST/write request, when reading data converter is not picking up and this debug message is printed:

2023-08-31 15:01:31.536 DEBUG 15628 --- [nio-8080-exec-1] c.s.o.j.processor.cb.impl.TypeConverter : No converter found to convert PGobject to GeospatialCollection

Could you elaborate what is happening here?

sahashmi commented 1 year ago

After I removed odata-jpa-processor-cb module then converter is working for reading data as well.