Spring Entity Postgres Point Field

时间:2017-09-01 00:42:52

标签: java spring postgresql jpa

我创建了一个JHipster项目,并且有一个名为Question的实体,它有一个点域。我并不十分关心我使用的Point类,但是我已经尝试了所有这些,org.postgresql.geometric.PGPointorg.geolatte.geom.Point,带转换器的自定义点类而且没有端。

@Column(name = "location") @Convert(converter=PointConverter.class) private Point location;

我现在正在尝试使用geolatte PostgisConverter<Point>,但我也有一个QuestionDTO课程。可以/我应该在

上添加转换器吗?

尝试保存问题实例时出现以下异常:

org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Can not construct instance of org.geolatte.geom.Point: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.geolatte.geom.Point: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?) at [Source: java.io.PushbackInputStream@6ec2b023; line: 8, column: 7] (through reference chain: com.dumdums.askaround.service.dto.QuestionDTO["location"]) at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:244) at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:229) at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:201) at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:150) at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:128) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:158) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)

我可以看到的任何示例或建议如何映射此字段?我在postgresql中使用point来执行cube/eartdistance查询,这样我就无法更改。

1 个答案:

答案 0 :(得分:0)

可以通过在值对象中提供默认构造函数来解决此类问题 QuestionDTO

请检查您是否有可用的默认构造函数 此外,请检查位置成员的设置者可见性(如果有)。