-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: GeoSpatial Question (Possibly UserType)
PostPosted: Mon Nov 01, 2004 10:50 am 
Newbie

Joined: Mon Nov 01, 2004 10:14 am
Posts: 2
Location: Sheffield, UK
Hibernate version: 2.1

Hiya all.. Perhaps this should go to the development list, I'm not sure. Apologies if the posting is in the wrong place.

I'm working on a project that needs to store spatial data indexed with spatial indexes. I'm currently working with MySQL, although in the past I've worked on Oracle Spatial databases too. I would like to be able to store values of a class such as Point and Polygon in the database.

Now, I'm aware that SQL-TYPE probably holds a short-term solution for me :) but I was wondering about the possibility of a longer term more complete solution to the problem. At first, I thought UserType might be the way to go, but I'm not sure what SQL Type the column would actually map on to (I've Seen GEOMETRY listed as a type but suspect it's always a local hack) or how to get the right function-wrappers called from the SQL. In MySQL the create table needs to be given a custom type (example below). At Insert/Select/Update time most of the access to the column is via a set of custom functions (MySQL functions being different to the Oracle ones, of course) that convert a string of comma seperated numbers into a hidden internal binary type. It feels to me like there is a need for an Abstract set of Geometry classes and then some extensions to the dialect mechanism to get the right function expressions for manipulating these columns in the database. It seems like the OpenGIS consortium has done a reasonable job of laying down the object model, it's essence is described quite nicely here: http://dev.mysql.com/doc/mysql/en/GIS_g ... archy.html.

Just for reference, an example of a create table with spatial data for oracle would be

CREATE TABLE mylake (
feature_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape MDSYS.SDO_GEOMETRY);

Wheras the MySQL one is more like

CREATE TABLE mylake (
feature_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape GEOMETRY);


Now, this isn't something I need right away, but it's something I'd be interested in looking into if nobody else is looking at it. Anyone think this is really dumb / good idea?

Cheers for your time,
Ian.


Top
 Profile  
 
 Post subject: Follow up
PostPosted: Fri Mar 04, 2005 2:06 pm 
Newbie

Joined: Fri Mar 04, 2005 2:02 pm
Posts: 18
Ian-

Did you find any solutions to this issue. I too am looking into UserTypes for supporting spatial types across vendors (Oracle, Sybase, and Informix). I haven't found any info out there on others that have tried this...

Don


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 10:50 am 
Newbie

Joined: Wed Sep 22, 2004 10:10 am
Posts: 15
Location: Darmstadt, Germany
We are actually developing a GIS that uses Hibernate and - among others - Oracle 9i Spatial. For the transformation of the SDO types offered by the Oracle DO java API to the standard java objects, we have written UserTypes, one per Geometry type (Point2D 1002, Point3D 1003, Polygon 2003...). We have also encapsulated the sdo_relate functions in a custom Criteria named SpatialExpression. Our current open point is how to make use of sdo_cs.transform functions - these would need to be applied on a per-column basis. Right now, I am investigating whether a Dialect variant might help...

Best Regards,

Thorsten


Top
 Profile  
 
 Post subject: Source code available?
PostPosted: Wed Dec 21, 2005 12:49 pm 
Newbie

Joined: Wed Dec 21, 2005 12:44 pm
Posts: 6
If the source code for your SDO_GEOMETRY UserType implementations is available anywhere, I would like to be able to use and contribute to the project! Here at NGDC we are moving from a Hibernate-like in-house solution to using Hibernate, but the SDO_GEOMETRY handling is a stumbling block and if there's an open-source solution already available we'd like to support that rather than try to roll our own.

If the code is not available under an open source license, I'll probably roll a solution based upon the geotools.org GeometryConverter interface, but this promises to be somewhat problematic because GeometryConverter requires a database connection to function, and I'm not sure whether or not this breaks the UserType implementation model.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 22, 2005 8:49 am 
Newbie

Joined: Wed Sep 22, 2004 10:10 am
Posts: 15
Location: Darmstadt, Germany
Hello!

First, using Geotools with its need of a database connection in the UserType context seems to be a bad idea to me, especially when thinking of caching and concurrency issues. These might be outweighted if all your subsequent processing logic is also bound to the types provided by geotools, but otherweise I would refrain from that path. We tried something similiar, even modifying Geotools so that they wouldn't need a database connection, but it proved to be much more work than a straigthforward conversion of the SDO types.

The code is unfortunately currently not available as open source. However, there are several ways I might be able to help you. For the discussion of these, I would ask you to contact me via e-Mail under thorsten.reitz@igd.fhg.de.
One is, we have been writing a technical/scientific paper on exactly that topic - connecting a ORDBMS with geospatial data to a geodata server. It describes quite in detail how we solved the different issues with handling SDO_GEOMETRY objects and the like. Since it is currently in the review process and the publication rights policies are quite strict, we would have to discuss a way in which I could give this to you now (it will be released ca. in 05/2006 accordinging to the publisher's schedule).
Another is that we might agree on a cooperative development of this part and could then give the source to you, or we might consult you on the topic :-). Anyway, I would definitely be interested in the scope and aim of your activities, if you are allowed to tell me anything about them.

Looking forward to hearing from you & best regards,

beelzebot


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 3:51 pm 
Newbie

Joined: Mon Jun 12, 2006 4:59 pm
Posts: 13
Here's how to map SDO_GEOMETRY to JGeometry using a UserType... all the code is there.

http://www.hibernate.org/Documentation/ ... oJGeometry


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 05, 2007 5:20 am 
Newbie

Joined: Thu Oct 27, 2005 4:07 am
Posts: 11
Quote:
ere's how to map SDO_GEOMETRY to JGeometry using a UserType... all the code is there.

http://www.hibernate.org/Documentation/ ... oJGeometry


This is written in "org.hibernate.usertype.UserType" JaveDoc:
Quote:
* This interface should be implemented by user-defined "types".
* A "type" class is <em>not</em> the actual property type - it
* is a class that knows how to serialize instances of another
* class to and from JDBC.


I tried the before mentioned example, but can't figure aut how to do get it running without using JGeometryType as the actual property type.

Thx

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 11:03 am 
Newbie

Joined: Mon Jun 12, 2006 4:59 pm
Posts: 13
Good call out! Sorry that it took so long for me to respond, my email wasn't working for quite some time.

Anyhow, you make a good point. I'll take a look at it again and see what I can do to make it possible to simple place the JGeometry into your EJB3 based entity bean.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 10:37 am 
Newbie

Joined: Wed Apr 11, 2007 8:48 am
Posts: 13
Hello

I am using Oracle Spatial and my table has a column of type SDO_Geometry. I did what was mentioned in: http://www.hibernate.org/Documentation/ ... oJGeometry.

heres how i am using the JGeometryType in my entity bean:

Code:
@Type(type="com.navsys.spatial.JGeometryType")
    @Column(name = "SHAPE", columnDefinition="oracle.spatial.geometry.JGeometry")
    private oracle.spatial.geometry.JGeometry shape;


Now when i call the entityManager.find() or findAll method to retrieve an entity i get the following exception:

Code:
Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not set a field value by reflection setter of Sample.shape
        at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:567)
        at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:56)
        at SampleFacade.findAll(SampleFacade.java:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
        at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
        at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)


Any help?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 9:00 am 
Newbie

Joined: Thu Oct 27, 2005 4:07 am
Posts: 11
>@Type(type="com.navsys.spatial.JGeometryType")
>@Column(name = "SHAPE",
> columnDefinition="oracle.spatial.geometry.JGeometry")
>private oracle.spatial.geometry.JGeometry shape;

the column definition should be
@Column(name = "shape", columnDefinition = "mdsys.sdo_geometry")

Peter


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.