there is a table containing a column of type SDO_GEOMETRY
representing some points. Later a spatial query like 'show all other points within distance x' shall be executed.
After pumping some data via sqlloader
into a import-table I am going to bring these datasets into a base-table while merging if business-key still exists.
My application is a executable jar using hibernate 5.0.9
, hibernate-spatial 5.0.9 final
, Oracle12c database and the hibernate.dialect has been
org.hibernate.dialect.Oracle12cDialect
before but now changed to
org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect
I know that there is only a spatial-dialect oficially for Oracle10 and also testet with oracle11 but with oracle12.
The problem now is, that the objects are stored via hibernate into base-table but inside the SDO-Geometry all coordinates are null (while the sdo_geometry object isnt).
select
businessKey,
my_sdo_geometry.sdo_point.x longitude,
my_sdo_geometry.sdo_point.y latitude
from my_import_table;
After sqlloader, all coordinates in import-table are shown well.
But after processing each import-dataset its column 'imported' {Y, N} is set to 'Y'. And doing so I am using myEntityManager.merge(importDataset)
. Due to this (although alle coordinates had been fine after sqlloader) the coordinates of the import-dataset are cleared to null.
//coordinates still viewable in database
importObject.setImported(Boolean.TRUE);
em.merge(importObject);
//coordinates null now
I guess that the spatial dialect is not working properly. I am afraid that this happens due to some incompatibility between last version of hibernate-spatial and oracle12c.
I am writing here with hope that there is anybody using hibernate-spatial successfully with oracle12 (to clarify that its possible at all) and to may get some help with any bad configuration on my side.
The persistance.xml of my application:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="myUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.ejb.cfgfile" value="/hibernate.cfg.xml" />
<property name="use_sql_comments" value="true" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@123.456.789.1:1234/cm" />
<property name="hibernate.connection.username" value="testMe" />
<property name="hibernate.connection.password" value="********" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect" />
</properties>
</persistence-unit> </persistence>
Thanks in advance.
edit: in the entity class the sdo_geometry column (here called 'Position') getter is annotated as follows:
@Column(name = "POSITION", nullable = false)
public Point getPosition() {
return this.position;
}
edit 2: after enabling hibernate sql trace, I found that hibernate is trying this update:
Hibernate: update IMPORT_TABLE set HB_VERSION=?, BUSINESS_KEY=?, IMPORTED=?, [...], POSITION=? where IMPORT_TABLE_ID=? and HB_VERSION=?
I am pointing to POSITION=?
which cannot be right I believe.
At this position I would expect the hibernate-dialect to take place.
May another hint to an imcompatibility with hibernate-dialect spatial10 and oracle12.