I have a Spring project where I access the database using Spring Data REST (using http://spring.io/guides/gs/accessing-data-rest/)
@RepositoryRestResource(collectionResourceRel = "test", path = "test")
public interface TestRepository extends PagingAndSortingRepository<Test, Long> {
@Query("SELECT max(p.lastUpdatedDate) FROM Test p")
Date findLastUpdatedDate();
}
When I try to access the above method to get the MAX date using the URL localhost:8080/test/search/findLastUpdatedDate, I get the error
{"cause":null,"message":"Cannot create self link for class java.sql.Timestamp! No persistent entity found!"}
Please suggest how can I get the max lastUpdatedDate from the Test table. Thanks!
Here is my Test class:
@Entity
@Table(name="test")
public class Test implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String col1;
private String col2;
private String status;
@Column(name = "last_updated_date")
private Date lastUpdatedDate;
// getters, setters, hashcode, equals, toString methods are written
}