Spring Data REST を使用してデータベースにアクセスする Spring プロジェクトがあります ( 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();
}
上記のメソッドにアクセスして、URL localhost:8080/test/search/findLastUpdatedDate を使用して MAX 日付を取得しようとすると、エラーが発生します。
{"cause":null,"message":"Cannot create self link for class java.sql.Timestamp! No persistent entity found!"}
Test テーブルから最大 lastUpdatedDate を取得する方法を提案してください。ありがとう!
ここに私のテストクラスがあります:
@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
}