【发布时间】:2015-09-11 19:10:51
【问题描述】:
我有一个实体人:
@Entity
public class Person implements Serializable {
@Id
@GeneratedValue(strategy = AUTO, generator = "PERSON_SEQ")
private Integer idPerson;
private String lastName;
private String firstName;
@Lob
private byte[] picture;
存储库
public interface PersonRepository extends PagingAndSortingRepository<Person, Integer> {}
投影
@Projection(name = "picture", types = { Person.class })
public interface ProjectionPicturePerson {
byte[] getPicture();
}
当我使用投影时:..../persons/1?projection=picture
我有这个错误
出现意外错误(类型=内部服务器错误,状态=500)。 无法写入内容:[B 无法转换为 [Ljava.lang.Object; (通过引用链:org.springframework.data.rest.webmvc.json.["content"]->$Proxy109["picture"]);嵌套异常是 com.fasterxml.jackson.databind.JsonMappingException: [B cannot be cast to [Ljava.lang.Object; (通过引用链:org.springframework.data.rest.webmvc.json.["content"]->$Proxy109["picture"])
当我在字符串上使用投影时,例如 lastName 它可以工作
@Projection(name = "lastName", types = { Person.class })
public interface ProjectionLastName {
String getLastName();
}
当我不使用投影时,它也可以工作
jackson序列化图片属性
对 Blob 有限制吗?
【问题讨论】:
标签: spring-data-jpa projection spring-data-rest