无法使用JPA插入PGpoint类型

Ecl*_*ica 5 java postgresql jpa postgis eclipselink

我正在尝试保留我的 JPA/EclipseLink 模型之一,location类型的一个属性org.postgresql.geometric.PGpoint未正确插入。

我的模型看起来像这样:

@Entity
@NamedQuery(name="Entity.findAll", query="SELECT * FROM Entity e")
public class Entity {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

@Column(name="name")
private String name;

@Column(name="location")
private PGpoint location;

@Column(name="date")
private Timestamp date;

@Column(name="user_id")
private Integer user_id;

/* getters and setters */
Run Code Online (Sandbox Code Playgroud)

我收到这个异常:

Internal Exception: org.postgresql.util.PSQLException: 
ERROR: column "location" is of type point but expression is of type bytea
Run Code Online (Sandbox Code Playgroud)

我已启用查询日志记录并确定问题似乎是由格式错误的 SQL 引起的。以下所有属性location似乎都被分组到一个bytea数组中。具体来说,JPA 尝试执行如下插入:

INSERT INTO ENTITY (name, location, date, user_id) 
VALUES ("my_name", [B26bf8d677, "2017-05-12 12:33:00.0", 1])
Run Code Online (Sandbox Code Playgroud)

也就是说,它似乎试图将最后三个属性全部插入到location列中。

我还尝试过存储location为 type String,它适用于我的其他模型之一,该模型仅从数据库读取位置值,从不插入它们。这似乎解决了格式错误的 SQL 问题,因为插入看起来像这样:

INSERT INTO ENTITY (name, location, date, user_id)
VALUES("my_name", "POINT(42,24)", "2017-05-12 12:33:00.0", 1)
Run Code Online (Sandbox Code Playgroud)

但是,由于我收到此异常,它实际上不起作用:

Internal Exception: org.postgresql.util.PSQLException: 
ERROR: column "location" is of type point but expression is of type character varying
Run Code Online (Sandbox Code Playgroud)

如何才能location正确插入属性?