【问题标题】:Issue with projection in SpringDataRest and @Lob attributeSpringDataRest 和 @Lob 属性中的投影问题
【发布时间】: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


    【解决方案1】:

    这是ProxyProjectionFactory 中的一个错误。我已为您提交并修复了DATACMNS-722,您计划在即将发布的服务版本中(下周中旬)。

    【讨论】:

    • 感谢 Oliver 的快速回复,也许我会在 SpringOne 见到你
    猜你喜欢
    • 1970-01-01
    • 2014-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多