<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>RE: [postgis-users] Hibernate with PostGIS</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>David,<BR>
<BR>
thanks, I will add that change to the code, and will write a test that with an EJB3 entity that has to create the columns in PostGIS automatically.  This should be directly analagous to hibernate.  I created my database first, and then mapped the pojos; I can understand that this isn't so desirable.<BR>
<BR>
Sandeep I will try to do this week, and resolve your issues with hibernate.<BR>
<BR>
Thanks for the fix, it was bad of me not to check whether the geom was null!  David are you from Pinan Software?  You are only a couple of miles down the road from me in the UK! <BR>
<BR>
Norman<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: postgis-users-bounces@postgis.refractions.net on behalf of Dave Potts<BR>
Sent: Sat 11/18/2006 5:07 PM<BR>
To: PostGIS Users Discussion<BR>
Subject: Re: [postgis-users] Hibernate with PostGIS<BR>
<BR>
First of all thank you Norman for writing the orginal code.<BR>
<BR>
There is a slight problem with it, it does not handle a null geometry<BR>
column, rewritting nullSafeGet as follows, fixes the problem.<BR>
<BR>
I can not say if it will address Sandeep problems, but it is worth trying.<BR>
<BR>
David.<BR>
<BR>
        /**<BR>
         * @see<BR>
org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet,<BR>
java.lang.String[], java.lang.Object)<BR>
         */<BR>
        public Object nullSafeGet(ResultSet resultSet,<BR>
                      String[] names, Object owner) throws<BR>
HibernateException, SQLException {<BR>
            Geometry result = null;<BR>
            String geom = resultSet.getString(names[0]);<BR>
            if(geom != null ) {<BR>
                BinaryParser parser = new BinaryParser();<BR>
                result = parser.parse(geom);<BR>
            }<BR>
            return result;<BR>
        }<BR>
<BR>
<BR>
Sandeep Kumar Jakkaraju wrote:<BR>
><BR>
> I think Hibernate cannot create that Geometry column automatically !!!<BR>
> is it something to do with hbm2ddl.auto !!<BR>
><BR>
><BR>
> I am able to ..get the geometry from a table with geometry column<BR>
> already created ...<BR>
><BR>
> Norman -->> Would you like me to create a simple tutorial on how to<BR>
> use Hibernate with Postgis ..your tutorial .. is not easy to<BR>
> understand ...<BR>
><BR>
><BR>
> Thanks<BR>
> Sandeep<BR>
><BR>
><BR>
><BR>
> ------------------------------------------------------------------------<BR>
><BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
>  <BR>
<BR>
_______________________________________________<BR>
postgis-users mailing list<BR>
postgis-users@postgis.refractions.net<BR>
<A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>