java - Postgis and Oracle spatial queries with GeometryUserType parameters -
following configuration of postgis , oracle spatial different hibernate persistence units , have instances of myclass persisted either postgis or oracle database configured in persistence.xml , mapping file.
i have geom attribute annotated :
public abstract class myclass (...) @type(type = "org.hibernatespatial.geometryusertype") @column(name = "geom", columndefinition="geometry", nullable = true) protected geometry geom; (...)
persistence.xml configured :
<persistence-unit name="pers_unit_name" transaction-type="jta"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <jta-data-source>jta_data_source_name</jta-data-source> <mapping-file>oracle.hbm.xml</mapping-file>
and in oracle.hbm.xml :
<hibernate-mapping> <typedef name="org.hibernatespatial.geometryusertype" class="org.hibernatespatial.geometryusertype" > <param name="dialect">org.hibernatespatial.oracle.oraclespatial10gdialect</param> </typedef> </hibernate-mapping>
postgis configuration work in similar way.
so when query myclass entities pick right dialect. seems work , pick right dialect attribute when inserting or retrieving info database (simple query.list()).
but when filtering on attribute parameter of type :
string querystring = "select new map(m.id, m.geom)" + "from myclass m " + "where within (r.geom, :geometry) = true "; final org.hibernate.query query = session.createquery(querystring); query.setparameter("geometry", geom, geometryusertype.type); return query.list();
it use hibernate dialect configured default particular parameter instead of specified persistence unit, output stacktrace below.
is there way can force use consistent dialect defined in persistence unit particular parameter field in predicate, instead of whatever configured default?
caused by: java.sql.sqlexception: invalid column type @ oracle.jdbc.driver.oraclepreparedstatement.setobjectcritical(oraclepreparedstatement.java:8921) @ oracle.jdbc.driver.oraclepreparedstatement.setobjectinternal(oraclepreparedstatement.java:8396) @ oracle.jdbc.driver.oraclepreparedstatement.setobjectinternal(oraclepreparedstatement.java:9176) @ oracle.jdbc.driver.oraclepreparedstatement.setobject(oraclepreparedstatement.java:9153) @ oracle.jdbc.driver.oraclepreparedstatementwrapper.setobject(oraclepreparedstatementwrapper.java:234) @ org.apache.tomcat.dbcp.dbcp2.delegatingpreparedstatement.setobject(delegatingpreparedstatement.java:188) @ org.apache.tomcat.dbcp.dbcp2.delegatingpreparedstatement.setobject(delegatingpreparedstatement.java:188) @ org.hibernatespatial.abstractdbgeometrytype.nullsafeset(abstractdbgeometrytype.java:154) @ org.hibernatespatial.geometryusertype.nullsafeset(geometryusertype.java:201) @ org.hibernate.type.customtype.nullsafeset(customtype.java:146) @ org.hibernate.param.namedparameterspecification.bind(namedparameterspecification.java:67) @ org.hibernate.loader.hql.queryloader.bindparametervalues(queryloader.java:578) @ org.hibernate.loader.loader.preparequerystatement(loader.java:1716) @ org.hibernate.loader.loader.doquery(loader.java:801) @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:274) @ org.hibernate.loader.loader.dolist(loader.java:2542)
Comments
Post a Comment