How to convert SDO_GEOMETRY to WKT in BlazeJPAQuery selection

Viewed 25

When running this code I expect to get a geometry object of type wkt, but instead I get the error written below. My database is Oracle database and I’m using Querydsl version 5.0.0

File CityResult.java

@Data
@Entity
@AllArgsConstructor
@Table(schema="PROD", name="CITIES")
public class CityResult implements Serializable {
    @Id
    @Column(name = "CITY_ID")
    private string cityId;
    @Column(name = "CITY_NAME")
    private String cityName;
    @Column(name = "CITY_GEO")
    private org.geolatte.geom.Geometry cityGeo;

    public CityResult(String cityId, String cityName, GeometryPath cityGeo) {
          this(cityId, cityName, Wkt.fromWkt(cityGeo.toString()));
}
}

File `CityQueryBuilder.java

@Component
@RequiredArgsConstructor(onConstructor = @__(Autowired)) 
public class CityQueryBuilder implemenets QueryBuilder<CityRequest, CityResult> {
    private final EntityManager entityManager;
    private final CriteriaBuilderFactory criteriaBuilderFactory;
    private final QCityResult table = QCityResult.cityResult;

    @override
    public BlazeJPAQuery<CityResult> buildQuery(CityRequest request){
        return new BlazeJPAQuery<CityResult>(this.entityManager, this.criteriaBuilderFactory)
            .select(Projections.constructor(CityResult.class, this.table.cityId, this.table.cityName,
                Expressions.template(GeometryPath.class, TemplateFactory.DEFAULT.
                        create("SDO_UTIL.TO_WKTGEOMETRY({0}) AS CITY_GEO"), this.table.cityGeo)))
            .from(this.table)
            .where(this.table.cityName.in(request.cityNames));
    }
}

Error

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.blazebit.persistence.parser.expression.SyntaxErrorException: Could not parse expression 'SDO_UTIL.TO_WKTGEOMETRY(cityResult.cityGeo) AS CITY_GEO', line 1:23 mismatched input '(' excepting {<EOF>, '.', '[', '+', '-', '*', '/', '%', '||'}
0 Answers
Related