【发布时间】:2020-07-14 17:17:51
【问题描述】:
我使用 Hibernate 执行此请求 @Subselect
SELECT сolumn1, array_agg(DISTINCT сolumn2::integer) FROM 表 GROUP BY сolumn1;
结果 SQL:
сolumn1 | сolumn2
------------+---------------------
1 | {1}
2 | {2,3}
3 | {3}
我的 DAO 类:
import lombok.Data;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Subselect;
import javax.persistence.*;
@Data
@Entity
@Subselect("SELECT сolumn1,\n" +
"\tarray_agg(DISTINCT сolumn2::integer)\n" +
"FROM table GROUP BY сolumn1;")
@Immutable
public class Table {
@Id
@Column(name = "сolumn1")
private Long сolumn1;
@Column(name = "сolumn2")
private Integer[] сolumn2;
}
现在不行了,出现错误:
message": "org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not deserialize; nested exception is org.hibernate.type.SerializationException: could not deserialize
List如何与array_agg映射?
【问题讨论】: