I found a similar problem here and tried to fix it, but it still does not work.
Using: Hibernate, Spring MVC
I have a @ManyToMany relationship between the entities Traveler and Address.
If I create the Traveler and Address individually by their own controller, it works. But if I try to create a Traveler and the appropriate Address by the following controller, I get a 400 Bad request error:
@RequestMapping(value = "/travelers", method=RequestMethod.POST)
public @ResponseBody Traveler createTraveler(@RequestBody Traveler traveler, Address address) {
logger.info("Start createTraveler");
System.out.println("Received traveler: " + traveler.getLastName());
travelerDAO.save(traveler);
System.out.println("Received address: " + address.getStreet());
addressDAO.save(address);
logger.info("End createTraveler");
return traveler;
}