<meta http-equiv="content-type" content="text/html; charset=utf-8"><div>Hi Fred,</div><div><br></div><div> In the function "dao.alterar(to, null, null);" it opens a new session to save. But, following your sugestion, I moved the "commit" line down and is happening the same problem.</div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div>[]'s</div><div><br></div><div>PA</div><div><br></div><div class="gmail_quote">On Thu, Aug 26, 2010 at 3:19 PM, Fred Lehodey <span dir="ltr"><<a href="mailto:lehodey@gmail.com">lehodey@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br><br>May be doing the commit after the setPoli... ?! :<br><br>to.setPoli(geom);<br>dao.commitTransaction(session, tx);<br>
<br>Fred<br><br><br><br><div class="gmail_quote"><div><div></div><div class="h5">On Thu, Aug 26, 2010 at 7:11 PM, Paulo Angelo <span dir="ltr"><<a href="mailto:pa@pauloangelo.com" target="_blank">pa@pauloangelo.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div></div><div class="h5">Hi Ppl,<br><br> I'm getting a weird problem. I can save a Geometry type through Hibernate but I can't retrieve it.<br>
<br><blockquote style="margin:0pt 0pt 0pt 40px;border:medium none;padding:0px">
WKTReader fromText = new WKTReader();<br> Geometry geom = fromText.read("POLYGON((0 0,0 3,3 3,3 0,0 0))");<br> Session session = dao.newSession();<br> Transaction tx = dao.beginTransaction(session);<br> Query q = session.createQuery("select f from Geometries f");<br>
List list = q.list();<br> Poligono to = (Poligono) lista.get(0);<br> dao.commitTransaction(session, tx);<br>to.setPoli(geom);<br> System.out.println(to.getPoli().toString()); // Apears "POLYGON ((0 0, 0 3, 3 3, 3 0, 0 0))"<div>
dao.alterar(to, null, null);</div><div> // I can see via SQL that it saves correctly</div><div><br></div><div>// Now, retrieve</div><div>session = dao.newSession();</div><div> tx = dao.beginTransaction(session);</div>
<div> q = session.createQuery("select f from Geometries f");</div><div> list = q.list();</div><div> to = (Poligono) lista.get(0);</div><div> dao.commitTransaction(session, tx);</div><div> System.out.println(to.getPoli().toString());</div>
<div> // Get a <b>NullPointerException</b>, because to.getPoli() is null</div></blockquote><div><br><br>The hibernate.cfg.xml<br>...<br> <property name="hibernate.dialect">org.hibernatespatial.postgis.PostgisDialect</property><br>
<property name="hibernate.show_sql">true</property><br> <property name="hibernate.cglib.use_reflection_optimizer">true</property><br> <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property><br>
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property><br>...<br><br>The poligono.hbm.xml<br>...<br> <property name="Poli" type="org.hibernatespatial.GeometryUserType"><br>
<column name="f0209_poli" sql-type="geometry"><br> <comment>Poligono</comment><br> </column><br> </property><br>...<br><br>The Poligono.java<br>
...<br>import com.vividsolutions.jts.geom.Geometry;<br>...<br> private Geometry poli;<br>...<br><br><br>What is wrong?<br><br>Thank you for help.<br><br>Att,<br><br>Paulo Angelo<br></div>
<br></div></div>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
<br></blockquote></div><br>
</blockquote></div><br>