hibernate-spatial 1.1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

hibernate-spatial 1.1

Farrukh Najmi
Hi Karel,

I am trying out the patch I submitted for http://www.hibernatespatial.org/jira/browse/HIBSPA-74 with my app.
But hibernate-spatial 1.1-SNAPSHOT is based on hibernate enitymanager 3.6 (my app is based on hiobernate 3.5) and there may have many other changes as well.

I am wondering if you can share any ETA for 1.1 release. Also do you have a list of major changes in hibernate-spatial 1.1-SNAPSHOT yet?
If 1.1 is too far out do you think we could do a minor release 1.0.1 that has the fix for HIBSPA-74?

In my hibernate-entitymanager 3.5 based code I did the following to specify a com.vividsolutions.jts.geom.Geometry objects as a filter parameter to a spatial query:

com.vividsolutions.jts.geom.Geometry filter = ...;
String queryStr = "SELECT Object(o) FROM mypkg.GeometryValueType AS o WHERE within(value_, :filter) = true";

javax.persistence.EntityManager em = ...;
javax.persistence.Query query = em.createQuery(queryStr);
           
//cast to Hibernate Query so as get access to the underlying Hibernate Query object.            
org.hibernate.Query hibernateQuery = ((org.hibernate.ejb.QueryImpl)query).getHibernateQuery();

// Set geometry value using CustomType
org.hibernate.type.Type geometryType = new org.hibernate.type.CustomType(org.hibernatespatial.GeometryUserType.class, null);
hibernateQuery.setParameter("filter", filter, geometryType);
       
List objs = query.getResultList();
It appears that a big change in my client code will be to align with AbstractDBGeometryType in place of the com.vividsolutions.jts.geom.Geometry.
So above code will likely look as follows (changes in bold font)....

org.hibernatespatial.AbstractGeometryType filter = ...;
String queryStr = "SELECT Object(o) FROM mypkg.GeometryValueType AS o WHERE within(value_, :filter) = true";

javax.persistence.EntityManager em = ...;
javax.persistence.Query query = em.createQuery(queryStr);
           
//cast to Hibernate Query so as get access to the underlying Hibernate Query object.            
org.hibernate.Query hibernateQuery = ((org.hibernate.ejb.QueryImpl)query).getHibernateQuery();

// Set geometry value using CustomType
org.hibernate.type.Type geometryType = new org.hibernate.type.CustomType(filter);
hibernateQuery.setParameter("filter", filter, geometryType);
       
List objs = query.getResultList();

Does this seem right?

Thanks for any advice you can provide.
-- 
Regards,
Farrukh Najmi

Web: http://www.wellfleetsoftware.com


_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: hibernate-spatial 1.1

Karel Maesen
Administrator
Hi,

On 04 Jan 2011, at 18:29, Farrukh Najmi wrote:

> Hi Karel,
>
> I am trying out the patch I submitted for http://www.hibernatespatial.org/jira/browse/HIBSPA-74 with my app.
> But hibernate-spatial 1.1-SNAPSHOT is based on hibernate enitymanager 3.6 (my app is based on hiobernate 3.5) and there may have many other changes as well.
>
> I am wondering if you can share any ETA for 1.1 release. Also do you have a list of major changes in hibernate-spatial 1.1-SNAPSHOT yet?

Not yet. I'm quite busy with other work, and I want to add some new functions to HS 1.1. See the road map on http://www.hibernatespatial.org/jira for release 1.1. There you see also the issues closed (and currently in trunk). Many other changes (not documented in JIRA) relate to the test framework (it is now more aligned with the Hibernate approach to integration testing).


> If 1.1 is too far out do you think we could do a minor release 1.0.1 that has the fix for HIBSPA-74?

I'll investigate, and check which changes I can merge from current trunk with Hibernate Spatial 1.0.). I'll get back to you on this.

> It appears that a big change in my client code will be to align with AbstractDBGeometryType in place of the com.vividsolutions.jts.geom.Geometry.
> So above code will likely look as follows (changes in bold font)....
>
> org.hibernatespatial.AbstractGeometryType
>  filter = ...;
> String queryStr = "SELECT Object(o) FROM mypkg.GeometryValueType AS o WHERE within(value_, :filter) = true";
>
> javax.persistence.EntityManager em = ...;
> javax.persistence.Query query = em.createQuery(queryStr);
>            
> //cast to Hibernate Query so as get access to the underlying Hibernate Query object.            
> org.hibernate.Query hibernateQuery = ((org.hibernate.ejb.QueryImpl)query).getHibernateQuery();
>
> // Set geometry value using CustomType
> org.hibernate.type.Type geometryType =
> new org.hibernate.type.CustomType(filter);
>
> hibernateQuery.setParameter("filter", filter, geometryType);
>        
> List objs = query.getResultList();
>
>
> Does this seem right?


This is not correct. AbstractDBGeometry does not replace JTS Geometry (and was already present in the code base from early versions of Hibernate Spatial). The only change to your code should be in the line that sets the query parameter.

It should be something like this:
        hibernateQuery.setParameter("filter", filter , new CustomType(new GeometryUserType()));

(With filter being a JTS Geometry object).

This change in client code is due to a change in Hibernate 3.6 of the setParameter() method signature.

Regards,

Karel






Regards,

Karel
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: hibernate-spatial 1.1

Farrukh Najmi

Hi Karel,

Please see inline below...

On 01/05/2011 04:28 PM, Karel Maesen wrote:
>> If 1.1 is too far out do you think we could do a minor release 1.0.1 that has the fix for HIBSPA-74?
> I'll investigate, and check which changes I can merge from current trunk with Hibernate Spatial 1.0.). I'll get back to you on this.

Thanks! I am very grateful.

>> It appears that a big change in my client code will be to align with AbstractDBGeometryType in place of the com.vividsolutions.jts.geom.Geometry.
>> So above code will likely look as follows (changes in bold font)....
>>
>> org.hibernatespatial.AbstractGeometryType
>>   filter = ...;
>> String queryStr = "SELECT Object(o) FROM mypkg.GeometryValueType AS o WHERE within(value_, :filter) = true";
>>
>> javax.persistence.EntityManager em = ...;
>> javax.persistence.Query query = em.createQuery(queryStr);
>>
>> //cast to Hibernate Query so as get access to the underlying Hibernate Query object.
>> org.hibernate.Query hibernateQuery = ((org.hibernate.ejb.QueryImpl)query).getHibernateQuery();
>>
>> // Set geometry value using CustomType
>> org.hibernate.type.Type geometryType =
>> new org.hibernate.type.CustomType(filter);
>>
>> hibernateQuery.setParameter("filter", filter, geometryType);
>>
>> List objs = query.getResultList();
>>
>>
>> Does this seem right?
>
> This is not correct. AbstractDBGeometry does not replace JTS Geometry (and was already present in the code base from early versions of Hibernate Spatial). The only change to your code should be in the line that sets the query parameter.
>
> It should be something like this:
> hibernateQuery.setParameter("filter", filter , new CustomType(new GeometryUserType()));
>
> (With filter being a JTS Geometry object).
>
> This change in client code is due to a change in Hibernate 3.6 of the setParameter() method signature.
>
>

This sounds much more manageable a change in my code than I thought.
Thanks for setting me straight.

--
Regards,
Farrukh Najmi

Web: http://www.wellfleetsoftware.com


_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users