Код: Выделить всё
@Entity
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String firstName;
private String lastName;
@Column(columnDefinition = "clob")
@Lob
private String description;
//getters and setters here
}
Код: Выделить всё
public interface PersonProjection {
String getLastName();
String getDescription();
}
Код: Выделить всё
@Repository
public interface PersonRepository extends PagingAndSortingRepository
{
@Query(value = "select pe.last_name as lastName, pe.description from person pe where pe.last_name = :lastName", nativeQuery = true)
List findAllByLastName(@Param("lastName") String lastName);
}
Код: Выделить всё
JSON_TEXTCONTAINSТеперь использование этого репозитория в контроллере приводит к:
Код: Выделить всё
Could not write JSON: Projection type must be an interface!; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Projection type must be an interface! (through reference chain: java.util.ArrayList[0]->com.sun.proxy.$Proxy103[\"description\"])
Полный проект по устранению этой проблемы можно найти здесь.
Подробнее здесь: https://stackoverflow.com/questions/538 ... erty-in-sp