Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What caused the "No property find found for type" spring data jpa error

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);
    }


}
like image 257
Pete_ch Avatar asked Dec 28 '12 07:12

Pete_ch


People also ask

What is Spring Data JPA which problem does it solve?

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.

What is @query used for spring data?

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.

What is Spring Data JPA explain its flow?

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.


1 Answers

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>{

}
like image 172
Ken Chan Avatar answered Nov 03 '22 18:11

Ken Chan