tipo inferido 'S' para el parámetro de tipo 'S' no está dentro de su límite; debe extenderse 'ua.com.store.entity.Country

Romano Sychok:

Tengo un problema con mi CountryServiceImpl, cuando quiero método se dan cuenta findOne en CountryServiceImpl me dice "tipo inferido 'S' para el parámetro de tipo 'S' no está dentro de su obligado; debería extenderse 'ua.com.store.entity.Country" .

Quería arreglar por mí mismo, pero no entiendo lo que significa esta. ¿Me puede ayudar con este problema.

Gracias.

@Entity
@Getter
@Setter
@NoArgsConstructor
@ToString
public class Country {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    private String countryName;

    @OneToMany(mappedBy = "country")
    private Set<Brand> brands = new HashSet<Brand>();
}


public interface CountryDAO extends JpaRepository<Country, Integer> {

    @Query("from Country c where c.countryName=:name")
    Country findByCountryName(@Param("name") String name);
}


public interface CountryService {

    void save(Country country);
    void delete(Country country);
    List<Country> findAll();
    Country findOne(int id);
    Country findByCountryName(String name);
}


@Service
public class CountryServiceImpl implements CountryService {

    @Autowired
    private CountryDAO dao;

    @Override
    public void save(Country country) {
        dao.save(country);
    }

    @Override
    public void delete(Country country) {
        dao.delete(country);
    }

    @Override
    public List<Country> findAll() {
        return dao.findAll();
    }

    @Override
    public Country findOne(int id) {
        return dao.findOne(id);
    }

    @Override
    public Country findByCountryName(String name) {
        return dao.findByCountryName(name);
    }
}
Lakshan:

documentación de Primavera define métodos getOne como sigue

<S extends T> Optional<S> findOne(Example<S> example)

En el método de su parámetro de entrada es 'id' de tipo int, pero no limitada al ejemplo de interfaz.

Para encontrar una entidad con ella 'id' se puede utilizar el método

Optional<T> findById(ID id)

De acuerdo con su aplicación puede escribirla

@Override
public Country findOne(int id) {
    return dao.findById(id);
}

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=173748&siteId=1
Recomendado
Clasificación