7

错误找不到类型 com.gridsearch.entities.Film 的属性

我的存储库

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

     }

我的服务

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

}

我的服务实现

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


}
4

2 回答 2

8

它应该Short代替short

public Film findOne(Short Id);

顺便说一句,您可以简单地扩展PagingAndSortingRepository已经提供该方法的方法findAll(Pageable page)

public interface FilmRepository extends PagingAndSortingRepository<Film,Short>{

}
于 2012-12-28T08:08:16.417 回答
2

我知道问题已得到解答,但我遇到了同样的问题,因为我在存储库中留下了一个旧方法,例如

public List<Entity> findByDateBetween(Long a, Long b)

虽然我的数据库中不再存在“日期”列。

于 2014-04-09T11:59:16.400 回答