问题描述
我有一个实体人员:
@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
我有这个错误
When i used the projection : ..../persons/1?projection=picture
i have this error
出现意外错误(类型=内部服务器错误,状态=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 它可以工作
When i use a projection on a String, exemple lastName it works
@Projection(name = "lastName", types = { Person.class })
public interface ProjectionLastName {
String getLastName();
}
当我不使用投影时它也能工作
When i don't use projection it works too
jackson 序列化图片属性
jackson serialize the image attribute
对 Blob 有限制吗?
Is there a restriction on Blob ?
推荐答案
这是 ProxyProjectionFactory
中的一个错误.我已经为您提交并修复了 DATACMNS-722 计划在即将发布的服务版本中(下周中旬).
That's a bug in ProxyProjectionFactory
. I've filed and fixed DATACMNS-722 for you scheduled to be in the upcoming services releases (mid next week).
这篇关于SpringDataRest 和 @Lob 属性中的投影问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!