<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Hibernate Spatial and Envers &#8211; Geospatial revisions</title>
	<atom:link href="http://claudiushauptmann.com/hibernate-spatial-and-envers-geospatial-revisions.html/feed" rel="self" type="application/rss+xml" />
	<link>http://claudiushauptmann.com/hibernate-spatial-and-envers-geospatial-revisions.html</link>
	<description>Rich Internet applications related stuff</description>
	<lastBuildDate>Wed, 21 Jul 2010 02:17:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Damian</title>
		<link>http://claudiushauptmann.com/hibernate-spatial-and-envers-geospatial-revisions.html/comment-page-1#comment-1164</link>
		<dc:creator>Damian</dc:creator>
		<pubDate>Sat, 19 Dec 2009 15:14:08 +0000</pubDate>
		<guid isPermaLink="false">http://claudiushauptmann.com/?p=253#comment-1164</guid>
		<description>Works beautifully! Thank you so much Claudius</description>
		<content:encoded><![CDATA[<p>Works beautifully! Thank you so much Claudius</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Claudius Hauptmann</title>
		<link>http://claudiushauptmann.com/hibernate-spatial-and-envers-geospatial-revisions.html/comment-page-1#comment-1163</link>
		<dc:creator>Claudius Hauptmann</dc:creator>
		<pubDate>Fri, 18 Dec 2009 20:19:10 +0000</pubDate>
		<guid isPermaLink="false">http://claudiushauptmann.com/?p=253#comment-1163</guid>
		<description>Hi Damian, thank you for your comments! You can&#039;t use JPA directly since JPA does not support extensions like HibernateSpatial, thus you have to ask your Query for the HibernateQuery and then you can add parameters of GeometryUserType:

			GeometryFactory geometryFactory = new GeometryFactory();
			WKTReader reader = new WKTReader(geometryFactory);
			Polygon polygon = (Polygon) reader.read(&quot;POLYGON((&quot; + north + &quot; &quot;
					+ west + &quot;, &quot; + north + &quot; &quot; + east + &quot;, &quot; + south + &quot; &quot;
					+ east + &quot;, &quot; + south + &quot; &quot; + west + &quot;, &quot; + north + &quot; &quot;
					+ west + &quot;))&quot;);
			polygon.setSRID(31466);

			Query q = em
					.createQuery(&quot;SELECT gf FROM GeonameFeature AS gf WHERE ((gf.featureClass=&#039;T&#039; AND (gf.featureCode=&#039;MT&#039; OR gf.featureCode=&#039;PK&#039;)) ) AND true = ST_within(gf.location, :within)&quot;);

			org.hibernate.ejb.QueryImpl hs = (QueryImpl) q;

			org.hibernate.Query hbQuery = hs.getHibernateQuery();

			hbQuery.setParameter(&quot;within&quot;, polygon, org.hibernate.Hibernate
					.custom(org.hibernatespatial.GeometryUserType.class));

			q.setParameter(&quot;within&quot;, polygon);
			q.setMaxResults(200);
			List&lt;GeonameFeature&gt; gfs = q.getResultList();</description>
		<content:encoded><![CDATA[<p>Hi Damian, thank you for your comments! You can&#8217;t use JPA directly since JPA does not support extensions like HibernateSpatial, thus you have to ask your Query for the HibernateQuery and then you can add parameters of GeometryUserType:</p>
<p>			GeometryFactory geometryFactory = new GeometryFactory();<br />
			WKTReader reader = new WKTReader(geometryFactory);<br />
			Polygon polygon = (Polygon) reader.read(&#8220;POLYGON((&#8221; + north + &#8221; &#8221;<br />
					+ west + &#8220;, &#8221; + north + &#8221; &#8221; + east + &#8220;, &#8221; + south + &#8221; &#8221;<br />
					+ east + &#8220;, &#8221; + south + &#8221; &#8221; + west + &#8220;, &#8221; + north + &#8221; &#8221;<br />
					+ west + &#8220;))&#8221;);<br />
			polygon.setSRID(31466);</p>
<p>			Query q = em<br />
					.createQuery(&#8220;SELECT gf FROM GeonameFeature AS gf WHERE ((gf.featureClass=&#8217;T&#8217; AND (gf.featureCode=&#8217;MT&#8217; OR gf.featureCode=&#8217;PK&#8217;)) ) AND true = ST_within(gf.location, :within)&#8221;);</p>
<p>			org.hibernate.ejb.QueryImpl hs = (QueryImpl) q;</p>
<p>			org.hibernate.Query hbQuery = hs.getHibernateQuery();</p>
<p>			hbQuery.setParameter(&#8220;within&#8221;, polygon, org.hibernate.Hibernate<br />
					.custom(org.hibernatespatial.GeometryUserType.class));</p>
<p>			q.setParameter(&#8220;within&#8221;, polygon);<br />
			q.setMaxResults(200);<br />
			List<geonamefeature> gfs = q.getResultList();</geonamefeature></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damian</title>
		<link>http://claudiushauptmann.com/hibernate-spatial-and-envers-geospatial-revisions.html/comment-page-1#comment-1162</link>
		<dc:creator>Damian</dc:creator>
		<pubDate>Fri, 18 Dec 2009 17:35:27 +0000</pubDate>
		<guid isPermaLink="false">http://claudiushauptmann.com/?p=253#comment-1162</guid>
		<description>If anybody stumbles upon your blog with the same problem, I managed to solve the above by placing my @Type(type=&quot;org.hibernatespatial.GeometryUserType&quot;) annotation above my getLocation() method instead of over the location property in my Entity.

Still, I&#039;d be interested to see how you coded spatial queries using JPA Claudius! :)

Great blog BTW.</description>
		<content:encoded><![CDATA[<p>If anybody stumbles upon your blog with the same problem, I managed to solve the above by placing my @Type(type=&#8221;org.hibernatespatial.GeometryUserType&#8221;) annotation above my getLocation() method instead of over the location property in my Entity.</p>
<p>Still, I&#8217;d be interested to see how you coded spatial queries using JPA Claudius! <img src='http://claudiushauptmann.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Great blog BTW.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damian</title>
		<link>http://claudiushauptmann.com/hibernate-spatial-and-envers-geospatial-revisions.html/comment-page-1#comment-1161</link>
		<dc:creator>Damian</dc:creator>
		<pubDate>Fri, 18 Dec 2009 15:45:58 +0000</pubDate>
		<guid isPermaLink="false">http://claudiushauptmann.com/?p=253#comment-1161</guid>
		<description>Hi - could you provide the code for this example? Or at least the portion of code that shows query/storage via the EntityManager.

I am able to get this working (ignoring envers) using pure hibernate but I would like to get it working using JPA instead.

Currently, I am encountering a serialisation problem when using the simplest of queries on a table which has a Geometry column e.g. 

Query query = em.createQuery(&quot;select b from Branch b&quot;);		
 
results in

 javax.persistence.PersistenceException: org.hibernate.type.SerializationException: could not deserialize
...
Caused by: java.io.StreamCorruptedException: invalid stream header: 30313031

Any help would be much appreciated.

Thanks in advance,
Damian</description>
		<content:encoded><![CDATA[<p>Hi &#8211; could you provide the code for this example? Or at least the portion of code that shows query/storage via the EntityManager.</p>
<p>I am able to get this working (ignoring envers) using pure hibernate but I would like to get it working using JPA instead.</p>
<p>Currently, I am encountering a serialisation problem when using the simplest of queries on a table which has a Geometry column e.g. </p>
<p>Query query = em.createQuery(&#8220;select b from Branch b&#8221;);		</p>
<p>results in</p>
<p> javax.persistence.PersistenceException: org.hibernate.type.SerializationException: could not deserialize<br />
&#8230;<br />
Caused by: java.io.StreamCorruptedException: invalid stream header: 30313031</p>
<p>Any help would be much appreciated.</p>
<p>Thanks in advance,<br />
Damian</p>
]]></content:encoded>
	</item>
</channel>
</rss>
