-->
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.  [ 1 post ] 
Author Message
 Post subject: How to Get com.vividsolutions.jts.geo.Point using hibernate
PostPosted: Thu Jan 02, 2014 3:24 pm 
Newbie

Joined: Thu Jan 02, 2014 3:17 pm
Posts: 1
I'm having a problem getting Geometry Points of type com.vividsolutions.jts.geo.Point and com.vividsolutions.jts.geo.Polygon using hibernate from my postgres database. I've tried a couple of different things and all have failed. Not sure if it has anything to do with it but my database stores the geometry datatypes as a long string of characters example of querying table for just this field:

track_position geometry(PointZ,4326) 010100000A0E6100000000000000000000000000000000000000000000000000000

In my java class for this table I have tried making the type a com.vividsolutions.jts.geo.Point com.vividsolutions.jts.geo.Geometry org.postgis.Geometry

When I run my query using both com.vividsolutions.jts.geo.Point and com.vividsolutions.jts.geo.Geometry Its able to parse the datatype and store it in my .java class However the value represented in the datatype shows up as Point( 0 0) and while debugging It shows 1 coordinate thats of type double and value of NaN which I understand to mean Not a Number.

When I change the datatype to type org.postgis.Geometry it fails to associate the two types and I get the following stack trace.

Jan 02, 2014 1:20:21 PM org.hibernate.property.BasicPropertyAccessor$BasicSetter set ERROR: HHH000123: IllegalArgumentException in class: database.model.TrackPoint, setter method of property: trackPosition Jan 02, 2014 1:20:21 PM org.hibernate.property.BasicPropertyAccessor$BasicSetter set ERROR: HHH000091: Expected type: org.postgis.Geometry, actual value: com.vividsolutions.jts.geom.Point Exception in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of database.model.TrackPoint.trackPosition at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:119) at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:710) at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:379) at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:4509) at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:186) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1108) at org.hibernate.loader.Loader.processResultSet(Loader.java:964) at org.hibernate.loader.Loader.doQuery(Loader.java:911) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342) at org.hibernate.loader.Loader.doList(Loader.java:2526) at org.hibernate.loader.Loader.doList(Loader.java:2512) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2342) at org.hibernate.loader.Loader.list(Loader.java:2337) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:495) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:357) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1269) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) at hibernatequerytest.HibernateQueryTest.main(HibernateQueryTest.java:36) Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:65) ... 19 more Java Result: 1 BUILD SUCCESSFUL (total time: 4 seconds)

I'm assuming the datatype should be com.vividsolutions.jts.geo.Point since thats what the query returns but I need to figure how to actually make it so it gets the value from the database. Any help is greatly appreciated.


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

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.