I have this entity that represents products stocked:
@Id
private String lotNumber;
@Id
@ManyToOne(cascade = CascadeType.MERGE)
@JoinColumn(name = "productId", foreignKey = @ForeignKey(name = "fk_product"), referencedColumnName = "productId")
private Products product;
@Id
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumns({
@JoinColumn(name = "id", foreignKey = @ForeignKey(name = "fk_billId")),
@JoinColumn(name = "supplier", foreignKey = @ForeignKey(name = "fk_billSupplier"))
})
private Bills bills;
Now everything works fine when presisting entities but when i fetch them in JSON format this is what i get:
"@lotNumber": "537fe03f-b261-48bb-b1dd-9215b5ad868a",
"lotNumber": "LOT001",
"product": {},
"bills": 7,
The product serialized as expected i removed its content to keep the message short, what is weird is how the bills entity serialized as just its Id from JsonIdentity().
I can’t find any mention of this behavior so can somebody explain why does this exactly happen?
1