I am new to spring I want to get all the data whose id=given by me. Can any one tell me how can I do That
@Override
public Collection<Device> listDevice() {
Collection<Device> deviceCollection=new ArrayList<>();
Iterable<Device> deviceIterable=deviceRepository.findAll();
for(Device d:deviceIterable){
deviceCollection.add(d);
}
return deviceCollection;
}
This is giving me all the data But I want data having id
long id=device.getManufacturer_id();
please tell how to do that
Instead of
Repository#findAll, useRepository#findById(ID primaryKey).Check this documentation:
http://docs.spring.io/spring-data/jpa/docs/1.0.0.M1/reference/html/