我正在尝试在 Micronaut Data JDBC 存储库中创建一个计数本机查询。我在用着:
@JdbcRepository(dialect = Dialect.POSTGRES)
public abstract class BookRepository implements GenericRepository<Book, Long> {
@Transactional(Transactional.TxType.MANDATORY)
@Query(value = "select count(*) FROM book WHERE registration_date > :date", nativeQuery = true)
public abstract long countNow(@NotNull Timestamp date);
}
我得到以下编译错误:
error: Unable to implement Repository method: BookRepository.countNow(Timestamp date). Query results in a type [my.app.db.Book] whilst method returns an incompatible type: long
我该如何解决这个问题?