Во-первых, и очень важно, вы НЕ используете String == String для проверки равенства. Ваш код:
public void updateRecipe(RecipeDTO recipedto, String id)
{
Recipe recipe = recipeRepository.findByrID(recipedto.getrID());
if(id==recipedto.getrID().toString())
{
recipeRepository.save(recipe);
}
}
Должно быть:
public void updateRecipe(RecipeDTO recipedto, String id)
{
Recipe recipe = recipeRepository.findByrID(recipedto.getrID());
if(recipedto.getrID().toString().equals(id))
{
recipeRepository.save(recipe);
}
}
Почему?
Поскольку равенство с == проверяет, имеют ли объекты одинаковый адрес памяти Другими словами:
new Integer(1) == new Integer(1) //false
1 == 1 //true
new String("hello") == new String("hello") //false
"hello" == "hello" //true because literal strings are stored in a String pool
new String("hello") == "hello" //false
Во-вторых, вы ДОЛЖНЫ ВСЕГДА использовать дженерики с API-интерфейсами Collection.
Ваш код:
List categoryList = new ArrayList<>();
Должно быть:
List<Category> categoryList = new ArrayList<>();
И, наконец, как сказал Аскепан, вы не определили, какую платформу вы используете. В случае Джерси (реализация JAX-RS) у вас есть методы HTTP-запроса:
@GET, @POST, @PUT, @DELETE, @HEAD, @ OPTIONS.
@PUT
@Produces("text/plain")
@Consumes("text/plain")
public Response putContainer() {
System.out.println("PUT CONTAINER " + container);
URI uri = uriInfo.getAbsolutePath();
Container c = new Container(container, uri.toString());
Response r;
if (!MemoryStore.MS.hasContainer(c)) {
r = Response.created(uri).build();
} else {
r = Response.noContent().build();
}
MemoryStore.MS.createContainer(c);
return r;
}
Если вы используете Spring, есть @RequestMapping (method =) или короткие версии:
@GetMapping, @PutMapping, @PostMapping, @ DeleteMapping.
@GetMapping("/{id}")
public Person getPerson(@PathVariable Long id) {
// ...
}
@PutMapping
public void add(@RequestBody Person person) {
// ...
}
Согласно аннотации, метод будет вызываться соответственно.
Больше информации в:
Весна JAX-RS