我正在将Spring boot和Hibernate一起用于空间查询。 使用的库: 1. Spring Boot-2.1.3.RELEASE 2.休眠空间-5.3.7.Final 3. MariaDB-MySQL Ver 15.1发行版10.1.36-MariaDB
每当我按以下查询中所述使用HQL时,在应用程序启动期间都会出现以下错误,但是当我尝试使用本机查询时,它将起作用。
我尝试使用不同的方言。另外,尝试将columnDefinition的值用作几何图形,geolatte-geometry。
pom.xml
<int:section>
application.yml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<exclusions>
<exclusion>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
当前,我在启动过程中遇到以下错误:
由以下原因引起:org.hibernate.hql.internal.ast.QuerySyntaxException:意外的AST节点:(在第1行第164列附近[从com.orange.alc.polygon.dao.entity.PolygonmasterEntity主节点中选择主节点, master.geometry,:point)]
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto: none
properties:
hibernate:
jdbc:
lob:
non_contextual_creation: true
physical_naming_strategy: com.orange.alc.polygon.dao.config.DefaultNamingStrategy
format_sql: false
dialect: org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect
@Entity
public class PolygonmasterEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// Here we have used Geolatte library
private Polygon geometry;
@Column(name = "is_active")
private Boolean active;
@Column(name = "is_deleted")
private Boolean deleted;
}
@Repository
public interface PolygonmasterRepository extends JpaRepository<PolygonmasterEntity,Long>,JpaSpecificationExecutor<PolygonmasterEntity> {
@Query("select master from #{#entityName} master WHERE"
+ " and within(master.geometry,:point)")
List<PolygonmasterEntity> findCostUsingPointForLLME(
@Param("point") Point point);
}