I just read an interessting statement in the "hibernate in action" book (p. 268) "Critera API doesn't provide any means for ... theta-style joins". Some posts in different forums confirmed that (e.g.
) but it'seems possible to use a subselect with joined table, like described in Post (
> Frank,
>
> I agree that it would be a worthwhile enhancement to Hibernate
> Spatial to be able to exploit spatial relations between tables.
> Either we can try to do it in the Criteria API, or in HQL (by
> defining the relevant functions in the dialect). But I'm not sure any
> of this will work.
>
> I would suggest to add an issue in JIRA for this, and I'll
> investigate it later.
>
> Regards,
>
> Karel
>
> On 10 Jun 2009, at 13:45,
[hidden email] wrote:
>
> > Thanks Karel!
> >
> > Could that be an issue as an enhancement to get Criterias defined
> > as an alternative way to write pur sql (see post http://
> > n2.nabble.com/Critera-and-SpatialRestrictions-with-geometries-from-
> > two-different-tables-tp3049602p3054325.html)? It could become
> > difficult to define an alias if there is no relation defined
> > between the classes and even no java-class exist for the joined
> > spatial table.
> >
> > Did nobody else has requirements like that? I don't want to
> > preselect the geometries from table A and query table B n-times
> > from clients side. That's was the database should do for me.
> >
> > The main reason why I would like to create an issue is: The dialect
> > has allready defined how the database function is named and with
> > the RelationshipMask it is still defined what kind of spatial
> > relations can be executed. Pur SQL can't use this definitions right
> > now, it's hard coded in OracleSpatialRestrictions ..
> >
> > What do you think. is there a way to get criterias defined without
> > having a geometry, only use the spatial relations within a database
> > between tables?
> >
> > That would be great!
> >
> > Thanks a lot,
> >
> > Frank
> >
> >
> >
> >
> >> Hi Frank,
> >>
> >>
> >> Here is a short example of a solution using the
> >> OracleSpatialRestrictions. Note that this works only with a query
> >> geometry and a geometry column, and not with two geometry columns in
> >> separate tables.
> >>
> >> mport org.hibernate.criterion.Criterion;
> >> import
> >> org.hibernatespatial.oracle.criterion.OracleSpatialRestrictions;
> >> import org.hibernatespatial.oracle.criterion.RelationshipMask;
> >> import org.hibernatespatial.oracle.criterion.SDOParameterMap;
> >> import com.vividsolutions.jts.geom.Polygon;
> >>
> >> ...
> >> Criteria criteria = session.createCriteria(Entity.class)
> >> //Create the SDOParameter map
> >> SDOParameterMap params = new SDOParameterMap();
> >> params.setMask("TOUCH+COVEREDBY");
> >> //Set the query geometry
> >> Polygon geom = ...;
> >> //create the Criterion. Shape is the geometry property in the Entity
> >> class
> >> Criterion c = OracleSpatialRestrictions.SDORelate("shape", geom,
> >> params);
> >> criteria.add(c);
> >>
> >> //Here is an alternative for creating the Criterion
> >>
> >> Polygon geom = null;
> >> RelationshipMask[] mask = new RelationshipMask[] {
> >> RelationshipMask.TOUCH,
> >> RelationshipMask.COVEREDBY
> >> };
> >> double minResolution = ....;
> >> double maxResolution = ...;
> >> Criterion c = OracleSpatialRestrictions.SDORelate("shape", geom,
> >> mask, minResolution, maxResolution);
> >> ...
> >>
> >> Regards,
> >>
> >> Karel
> >>
> >>
> >> On 10 Jun 2009, at 10:31,
[hidden email] wrote:
> >>
> >>> Hello again,
> >>>
> >>> I just found a solution but I don't use hibernatespatial (except
> >>> for maping the result to a class haveing a geometry attribute)
> >>> anymore:
> >>>
> >>> [....]
> >>> session.beginTransaction();
> >>> List results = session.createSQLQuery(
> >>> "SELECT a.* FROM polygons a,
> >>> query_polys B \n" +
> >>> " WHERE b.name = 'a name' \n" + //
> >>> TODO use a named binding here
> >>> " AND SDO_RELATE(A.Geometry,
> >>> B.Geometry, 'mask=touch+inside') = 'TRUE' ", "a",
> >>> MyClass.class).list();
> >>> [....]
> >>>
> >>>
> >>> Cheers,
> >>>
> >>> Frank
> >>> _______________________________________________
> >>> hibernatespatial-users mailing list
> >>>
[hidden email]
> >>>
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/> >>> hibernatespatial-users
> >>
> >> _______________________________________________
> >> hibernatespatial-users mailing list
> >>
[hidden email]
> >>
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/
> >> hibernatespatial-users
> >>
> >
> >
> > _______________________________________________
> > hibernatespatial-users mailing list
> >
[hidden email]
> >
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/
> > hibernatespatial-users
>
> _______________________________________________
> hibernatespatial-users mailing list
>
[hidden email]
>
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users>