Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hibernate Spatial support #692

Closed
timowest opened this issue Mar 31, 2014 · 13 comments
Closed

Hibernate Spatial support #692

timowest opened this issue Mar 31, 2014 · 13 comments
Labels
Milestone

Comments

@timowest
Copy link
Member

@timowest timowest commented Mar 31, 2014

Hibernate Spatial support

Challenges

@timowest timowest added the feature label Mar 31, 2014
timowest added a commit that referenced this issue Apr 9, 2014
@jcagarcia
Copy link

@jcagarcia jcagarcia commented Sep 9, 2014

Hi,

I'm trying to use INTERSECTS operation and when generates BooleanExpression i'm getting the following message:

unknown operation with operator com.mysema.query.spatial.SpatialOps#INTERSECTS and args [entity.location, POLYGON((30 10,40 40,20 40,10 20,30 10))]

I'm using HibernateSpatial.. then i'm trying to do the following:

Create my own class based on your HibernateSpatialSupport to create a valid intersects operation to use on HibernateSpatial.

I've created an HibernateSpatialOps with:

private static final String NS = HibernateSpatialOps.class.getName();
public static final Operator<Object> INTERSECTS = new OperatorImpl<Object>( NS, "intersects({0}, {1})");

When i generate BooleanExpression with intersects operation appears the following message:

unknown operation with operator org.project1.querydsl.HibernateSpatialOps#intersects({0}, {1}) and args [entity.location, POLYGON ((-0.948944091796875 39.49052944781087, -0.4988479614257812 39.49052944781087, -0.4988479614257812 39.39030533696812, -0.948944091796875 39.39030533696812, -0.948944091796875 39.49052944781087))]

Can you help me?

Best Regards,

@jcagarcia
Copy link

@jcagarcia jcagarcia commented Sep 11, 2014

Finally I found a solution to solve it.

I've create an HibernateSpatialTemplate that gets ops values from your /test/HibernateSpatialSupport and pass when constructs JPAQuery...

On the other hand i'm using JTS instead of geolate types...I've implemented GeometryExpression, GeometryPath, etc... To recive JTS items... Do you think is a good solution?

@timowest
Copy link
Member Author

@timowest timowest commented Sep 11, 2014

I am preparing support for it in this branch https://github.com/querydsl/querydsl/tree/i692

It is a similar solution like yours, but still needs the code generation side to be implemented.

@jcagarcia
Copy link

@jcagarcia jcagarcia commented Sep 12, 2014

Perfect!

Thank you for your work!!

Best Regards,

@timowest
Copy link
Member Author

@timowest timowest commented Sep 25, 2014

@jcagarcia Could you try the new PR I provided? It should give you also the code generation side and automatically register the spatial operations in HQLTemplates.

@steventhomson
Copy link

@steventhomson steventhomson commented Oct 10, 2014

@timowest
This will be a great addition the the library! My team is also using hibernate spatial.

I pulled the PR and built the project locally. Then I added the dependency to my project, all is well. I am having trouble generating the code in maven. Could you possibly point me to a sample project or configuration example.

I've tried the configuration from here: http://www.querydsl.com/static/querydsl/3.4.3/reference/html_single/#spatial with no luck. The QClass that is generated has the Geolatte Geometry type as SimplePath instead of GeometryPath. If I try JTS Geometry I get ComparablePath instead of GeometryPath.

Thanks in advance,
Steve

@steventhomson
Copy link

@steventhomson steventhomson commented Oct 13, 2014

@jcagarcia I was wondering if you could provide a link to your solution?

@timowest
Copy link
Member Author

@timowest timowest commented Oct 13, 2014

@steventhomson There is not yet an example project for that. The configuration in the reference docs is for code generation based on JDBC schema inspection. If you want to use JPA annotations instead you should be able to get the desired results using this configuration http://www.querydsl.com/static/querydsl/3.5.0/reference/html/ch02.html#d0e123

@steventhomson
Copy link

@steventhomson steventhomson commented Oct 13, 2014

@timowest Thanks for the reply! I will try the configuration you pointed out.

@steventhomson
Copy link

@steventhomson steventhomson commented Oct 20, 2014

@timowest The JPA configuration did work for the geolatte geometry type.

@steventhomson
Copy link

@steventhomson steventhomson commented Oct 24, 2014

@timowest I submitted a pull request that adds JTS Geometries support here: #1011

Let me know if you have any questions or comments.

Thanks again as this lets my team move forward combining spatial queries with regular attribute queries!

@steventhomson
Copy link

@steventhomson steventhomson commented Oct 25, 2014

As suggested pull request #1011 closed and a new one opened with the correct branch here: #1012

@timowest timowest added this to the 3.6.0 milestone Nov 1, 2014
@timowest
Copy link
Member Author

@timowest timowest commented Nov 30, 2014

Released in 3.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.