Hi guys,
According to the Querydsl spatial reference (here), the code generation for Querydsl SQL can be set to detect the usage of spatial types in database schemas and use geolatte types in these case via the spatial property:
<project>
<build>
<plugins>
...
<plugin>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>${querydsl.version}</version>
...
<configuration>
...
<spatial>true</spatial>
</configuration>
</plugin>
...
</plugins>
</build>
</project>
However, I still get the argument type mismatch when I read the geometry column from postgis DB. This error occurs in QBean newInstance() method. It looks like when it do the invoke setter.invoke(rv, value), the data type read in (value) is org.postgis.PGgeometry and Querydsl expect org.geolatte.geom.Geometry when I create the GeometryPath in th QFile. Following is part of the code.
In the QAddress.java, I create the GeometryPath as below:
public final GeometryPath<Geometry> location = createGeometry("location", Geometry.class);
Then, I did the following to query from postgres db (with postgis installed)
queryFactory.select(addressBean) .from(QAddress.address) .fetch();
My addressBean was defined as
private final QBean<AddressWrapper> addressBean = Projections.bean(AddressWrapper.class, ... QAddress.address.location, ...);
The AddressWrapper class is like this
public class AddressWrapper implements AvroWrapper<Address> { private final Address.Builder mBuilder; public AddressWrapper() { mBuilder = Address.newBuilder(); } ... public void setLocation(Geometry location) { mBuilder.setLocation(Wkt.toWkt(location)); } ... @Override public Address build() { return mBuilder.build(); } }
Any clue why the code generation via Maven in the querydsl reference is not working? Or anyone know either how I can create GeometryPath location = createGeometry("location", T.class) using org.postgis.PGGeometry
type? Or anyway I can read data from DB with type org.geolatte.geom.Geometry
?
Please help.