Issue Details (XML | Word | Printable)

Key: NUCSPATIAL-7
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Jan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Types : Geospatial

GeometryMapping (JTS) ArrayIndexOutOfBoundsException when using input parameters due to "cloneMapping"

Created: 27/Nov/09 01:15 PM   Updated: 21/Apr/10 07:39 PM   Resolved: 14/Dec/09 09:55 AM
Component/s: None
Affects Version/s: 1.0.2, 1.1.0.release, 2.0.0.m1
Fix Version/s: 2.0.0.release

Environment: Linux, Java6, PostGIS, PostgreSQL 8.3

Forum Thread URL: http://www.jpox.org/servlet/forum/viewthread_thread,5868
Datastore: PostgreSQL
Severity: Development


 Description  « Hide
Report for original Problem: http://www.jpox.org/servlet/forum/viewthread_thread,5868.

java.lang.ArrayIndexOutOfBoundsException: 0
        at org.datanucleus.store.mapping.jts.GeometryMapping.cloneMapping(GeometryMapping.java:206)
        at org.datanucleus.store.mapping.jts.GeometryMapping.newLiteral(GeometryMapping.java:187)
        at org.datanucleus.store.rdbms.query.JDOQLQueryCompiler.compileNamedImplicitParameter(JDOQLQueryCompile
r.java:1148)
        at org.datanucleus.store.rdbms.query.JDOQLQueryCompiler.compileIdentifier(JDOQLQueryCompiler.java:885)
        at org.datanucleus.store.rdbms.query.JDOQLQueryCompiler.compilePrimary(JDOQLQueryCompiler.java:774)
        at [...]

When cloning the Geometry, the field GeometryMapping.datastoreMappings has a length of 0. This seems to happen, because it is never initialized. And this seems to be because hasSimpleDatastoreRepresentation() returns false. I don't understand the semantic of "simpleDatastoreRepresentation" but I've overridden the method and it works so far - I don't know what side affects can appear.

Hope this report will help you in fixing the issue. Still I don't understand why this has not happened to anyone else, yet? I just use DN, JTS, Postgis and Geometries as parameter in JDOQL.

Jan

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 27/Nov/09 06:06 PM
*.jts.GeometryMapping cannot have hasSimpleDatastoreRepresentation simply set to true since it may have multiple columns ... as per the initialize method of GeometryMapping use of "addDatastoreField()". So if it doesn't have any datastore fields then it isn't being initialised.

Sadly the people who wrote this code disappeared elsewhere some time ago and didn't leave any real docs for how their provided testcases etc are run, and commercial clients haven't requested use of this plugin, hence it gets low priority

Jan added a comment - 27/Nov/09 06:36 PM
Ok, then I'll test it and submit a patch if I found the problem. Maybe I can work with the testcases you mentioned in the svn.

Thanks,

Jan

Jan added a comment - 11/Dec/09 09:55 PM
This is a patch for JTS Geometries. Still, I don't know why it worked for the original authors before. It might me a question of how much columns are needed to store the object, either 1 (without jts user object) or 2 (with jts user object).

Cheers,

Jan

Andy Jefferson added a comment - 13/Dec/09 10:24 AM
As already mentioned, you cannot just make that a "SimpleDatastoreRepresentation" since it can have multiple columns, hence cannot apply that patch. Thx

Andy Jefferson added a comment - 13/Dec/09 10:53 AM
i.e problem is specific to this "cloneMapping" method, which in turn is specific to Spatial, so almost certainly it is not setting all things necessary on a mapping

Andy Jefferson added a comment - 14/Dec/09 09:55 AM
Doesn't happen with SVN trunk codebase