Use PostGIS columns transparently in Hibernate -
i have postgresql table contains, among many other columns, spatial column point
. spatial column should give contents in geojson-format.
a normal sql should this:
class="lang-sql prettyprint-override">select column1, column2, column3, st_asgeojson(point) table;
and writeback:
class="lang-sql prettyprint-override">update table set column1 = 'abc', column2 = 'def', column3 = 'ghi', point = st_geomfromgeojson('{ ... geojson ... }') id = ??;
i know there extension hibernate called hibernate-spatial. extension postgis 1.5 can read geojson, not parse , write geojson postgresql. disadvantage: spatial operations (like conversions) done on server-side, not on database-side.
is there possibility inject sql-function query this:
class="lang-java prettyprint-override">entitymanager em = emfactory.createentitymanager(); mymodel selected = em.find(mymodel.class, 1);
in mymodel used column geometry should string
or inherited type of string represents geojson.
i found hibernate dialects seems work on hql (or jpl). utilize geojson transparently - not in combination hql (where forced write sql in code, don't want).
it possible utilize setcustomwrite
, setcustomread didn't find examples how utilize them.
to prevent answers why leave type in postgis-geometry - should left in type because of other spatial-related operations on db-side.
dialect hibernate have utilize postgres driver...
hibernate postgis
No comments:
Post a Comment