Issue with projection in SpringDataRest and @Lob attribute

夙愿已清 提交于 2019-12-25 06:21:58

问题


I have an Entity Person :

@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;

A repository

public interface PersonRepository extends PagingAndSortingRepository<Person, Integer> {}

A projection

@Projection(name = "picture", types = { Person.class })
public interface ProjectionPicturePerson {
  byte[] getPicture();

}

When i used the projection : ..../persons/1?projection=picture i have this error

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

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 serialize the image attribute

Is there a restriction on Blob ?


回答1:


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).



来源:https://stackoverflow.com/questions/31045930/issue-with-projection-in-springdatarest-and-lob-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!