SpringDataRest 和 @Lob 属性中的投影问题 [英] Issue with projection in SpringDataRest and @Lob attribute

查看:53
本文介绍了SpringDataRest 和 @Lob 属性中的投影问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实体人员:

@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"])

There was an unexpected error (type=Internal Server Error, status=500). Could not write content: [B cannot be cast to [Ljava.lang.Object; (through reference chain: org.springframework.data.rest.webmvc.json.["content"]->$Proxy109["picture"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: [B cannot be cast to [Ljava.lang.Object; (through reference chain: 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 属性中的投影问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆