With or without this annotation, there is a property on my JPA @Entity
@Entity
public class Myentity extends ResourceSupport implements Serializable {
...
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name="idrepository")
@JsonInclude(JsonInclude.Include.ALWAYS)
private MyentitySource entitysource;
...
}
that is not being mapped when I return:
@RequestMapping("/myentity/{uuid}")
public ResponseEntity<Myentity> getResourceById(@PathVariable("uuid") UUID uuid) {
Myentity result = myentityRepository.findOne(uuid);
return ResponseEntity.ok(myentityAssembler.toResource(result));
}
myentityAssembler.toResource(result)
does contain this MyentitySource entitysource
, but the JSON output does not.
The weirdest thing is I have another spring boot hateoas project where I am using the exact same entity, repository, controller, and assembler implementations, with the exact same dependencies and versions on my pom, and a very similar configuration (I am not defining any special jackson mappers or anything, just using the default rest/hateoas configuration), and it does work there: The MyentitySource entitysource
property, which is another JPA entity extending ResourceSupport, gets serialized and included into the JSON output.
I have been a couple of hours at it already, but I am quite lost. I have verified this behavior is happening all through the application in both applications: @ManyToOne
relations defined on any @Entity
are being mapped and present in the JSON output on one application, but not in the other.
How can I get these fields to show up on the JSON output?