+ "FROM \"schema\".\"road\" "
+ "WHERE \"geom\".Filter(geometry::STGeomFromText('POLYGON ((2 -1, 2 5, 4 5, 4 -1, 2 -1))', 4326)) = 1 "
+ "AND geometry::STGeomFromText('POLYGON ((2 -1, 2 5, 4 5, 4 -1, 2 -1))', 4326).STContains(\"geom\") = 1");
// the filter for the Query
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
GeometryFactory gf = new GeometryFactory();
PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
LinearRing shell = gf.createLinearRing(sf.create(new double[] { 2, -1, 2, 5, 4, 5, 4, -1,
2, -1 }, 2));
Polygon polygon = gf.createPolygon(shell, null);
Contains cs = ff.contains(ff.literal(polygon), ff.property(aname("geom")));
SimpleFeatureType roadSchema = dataStore.getSchema("road");
originalSchema = dataStore.getDatabaseSchema();
dataStore.setDatabaseSchema("schema");
dialect.handleSelectHints(sql1, roadSchema, new Query("road", cs));