[postgis-users] Hibernate with PostGIS

Dave Potts dave.potts at pinan.co.uk
Sat Nov 18 09:07:48 PST 2006


First of all thank you Norman for writing the orginal code.

There is a slight problem with it, it does not handle a null geometry 
column, rewritting nullSafeGet as follows, fixes the problem.

I can not say if it will address Sandeep problems, but it is worth trying.

David.

        /**
         * @see 
org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, 
java.lang.String[], java.lang.Object)
         */
        public Object nullSafeGet(ResultSet resultSet,
                      String[] names, Object owner) throws 
HibernateException, SQLException {
            Geometry result = null;
            String geom = resultSet.getString(names[0]);
            if(geom != null ) {
                BinaryParser parser = new BinaryParser();
                result = parser.parse(geom);
            }
            return result;
        }


Sandeep Kumar Jakkaraju wrote:
>
> I think Hibernate cannot create that Geometry column automatically !!!
> is it something to do with hbm2ddl.auto !!
>
>
> I am able to ..get the geometry from a table with geometry column 
> already created ...
>
> Norman -->> Would you like me to create a simple tutorial on how to 
> use Hibernate with Postgis ..your tutorial .. is not easy to 
> understand ...
>
>
> Thanks
> Sandeep
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>   




More information about the postgis-users mailing list