the error No property find found for type com.gridsearch.entities.Film
my repository
package com.gridsearch.repository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;
import com.gridsearch.entities.Film;
public interface FilmRepository extends CrudRepository<Film,Short>{
public Page<Film> findAll(Pageable page);
public Film findOne(short Id);
}
my service
package com.gridsearch.service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.gridsearch.entities.Film;
public interface FilmService {
public Page<Film> allFilms(Pageable page);
public Film findOne(int Id);
}
my service implementation
package com.gridsearch.service;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.gridsearch.entities.Film;
import com.gridsearch.repository.FilmRepository;
@Repository
public class FilmServiceImpl implements FilmService{
@Autowired
private FilmRepository repository;
@Transactional
public Page<Film> allFilms(Pageable page) {
return repository.findAll(page);
}
@Override
public Film findOne(int id) {
return repository.findOne((short) id);
}
}
JPA handles most of the complexity of JDBC-based database access and object-relational mappings. On top of that, Spring Data JPA reduces the amount of boilerplate code required by JPA. That makes the implementation of your persistence layer easier and faster.
Spring Data JPA @Query The @Query annotation declares finder queries directly on repository methods. While similar @NamedQuery is used on domain classes, Spring Data JPA @Query annotation is used on Repository interface. This frees the domain classes from persistence specific information, which is a good thing.
Spring Data JPA aims to significantly improve the implementation of data access layers by reducing the effort to the amount that's actually needed. As a developer you write your repository interfaces, including custom finder methods, and Spring will provide the implementation automatically.
It should be Short
instead of short
:
public Film findOne(Short Id);
By the way , you can simply extend PagingAndSortingRepository
which already provides the method findAll(Pageable page)
:
public interface FilmRepository extends PagingAndSortingRepository<Film,Short>{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With