I've got problem with Spring @Query
annotation. It returns me nothing from postgresql despite of that there are a lot of records. I suppose that it is because of the fact that in db is eg. section_id instead of section column.
From method bellow I have all data.
@Query("select p.id, p.dataContentType, p.changeDate, p.name, p.section.id, p.line.id, p.type.id, "
+ "p.status.id, p.changeUser.id, p.insertDate, p.deletedDate, p.recNum, p.actual, p.previous.id, p.thumbnail "
+ "from Picture p where p.actual=true")
Page<Object[]> findAllWithoutData(Pageable pageable);
However I need method like bellow which returns me Picture:
@Query("select new Picture(p.id, p.dataContentType, p.changeDate, p.name, p.section, p.line, p.type, "
+ "p.status, p.changeUser, p.insertDate, p.deletedDate, p.recNum, p.actual, p.previous, p.thumbnail) "
+ "from Picture p where p.actual=true")
Page<Picture> findAllWithoutData(Pageable pageable);
Here's my entity:
public class Picture implements Serializable {
private Long id;
private byte[] data;
private String dataContentType;
private ZonedDateTime changeDate;
private String name;
private Section section;
private Line line;
private DictionaryValue type;
private DictionaryValue status;
private User changeUser;
private ZonedDateTime insertDate;
private ZonedDateTime deletedDate;
private Long recNum;
private Boolean actual;
private Picture previous;
private byte[] thumbnail;
public Picture(Long id, String dataContentType, ZonedDateTime changeDate, String name, Section section,
Line line, DictionaryValue type, DictionaryValue status, User changeUser, ZonedDateTime insertDate,
ZonedDateTime deletedDate, Long recNum, Boolean actual, Picture previous, byte[] thumbnail) {
this.id = id;
this.dataContentType = dataContentType;
this.changeDate = changeDate;
this.name = name;
this.section = section;
this.line = line;
this.type = type;
this.status = status;
this.changeUser = changeUser;
this.insertDate = insertDate;
this.deletedDate = deletedDate;
this.recNum = recNum;
this.actual = actual;
this.previous = previous;
this.thumbnail = thumbnail;
}