Reputation: 363
I am working on a Spring-boot, maven project where I query a MySQL database by the use of hibernate, static metamodels and (org.springframework.data.jpa.domain.)Specification's. My metamodels are autmatically generated by the Hibernate JPA 2 Metamodel Generator. I am using the com.vividsolutions.jts.geom classes for my spatial fields.
I am struggeling for a while now to include those geometry fields in my metamodel since the metamodel generator seems to ignore those. Is there any workaround for this without any major changes? For what I understand, my configuration should work.
A bit more info:
Hibernate dialect: org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect
Pom:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<optional>true</optional>
<version>5.2.10.Final</version>
</dependency>
Java version 1.8
The annotation processing is handled within my IDE (Eclipse)
In my entities the geometry fields are defined like so
@Column(name="POLYGON", columnDefinition="Geometry")
private Polygon polygon;
Any guidance in the right direction will be greatly appreciated.
Upvotes: 1
Views: 1478
Reputation: 179
With Hibernate 5.3.10, adding the @Basic annotation did the trick, together with adding @Access(AccessType.FIELD) to the class. Without the Access annotation the Geometry type will not appear in the JPA metamodel.
Upvotes: 5
Reputation: 146
I have the same problem in my project and I worked around it with JPA custom queries.In the query add function - "GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')" -> https://dev.mysql.com/doc/refman/5.6/en/populating-spatial-columns.html and then it worked.
Upvotes: 0