2

I have an existing MySQL database with a column in a table that has a "point" data type. The first thing I did was add the spatial dependency to our gradle build file via:

implementation 'org.hibernate:hibernate-spatial:5.4.2.Final'

I'm struggling to figure out exactly how to modify our mapping file (it's XML based, not using annotations) and the corresponding model to support loading this.

    <property name="pickupLocation" type="???">
        <column name="pickup_location" sql-type="???"/>
    </property>

From what I've gathered in the small subset of examples I can find online, I need it to end up in a: com.vividsolutions.jts.geom.Point data type in my model. That's essentially all I have on the model end. I would assume that sql-type should just be "point", but recognize that might be an inaccurate assumption. No matter what combination of types/sql-types I try, I generally end up with a deserialization error in an obscure stack trace that's not particularly helpful.

If it's relevant, I seeded the data in the table via: SET pickup_location=POINT(18 -63).

1 Answer 1

2

As long as pickupLocation is of type JTS Point, no type or sql-type should be necessary in the mapping file.

You may want to check that your application is actually using a Spatial Dialect (see the manual for available dialects). It is the most common source for this type of problem.

In any case, the value point is correct for sql-type, and for type it should be jts_geometry.

Sign up to request clarification or add additional context in comments.

1 Comment

For posterity, this proved accurate. Was able to solve it last evening. I had already converted to a Spatial dialect. The mapping file didn't need either a type or a sql-type as you said. I had to convert the Point to a org.locationtech.jts.geom.Point instead of the vividsolutions type, which was the bit that finally made it work. After turning on TRACE level debugging, it became a bit more clear. Thanks for the response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.