Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
I have this entity that represents products stocked:
private String lotNumber;
@ ManyToOne ( cascade = CascadeType. MERGE )
@ JoinColumn ( name = "productId" , foreignKey = @ ForeignKey ( name = "fk_product" ) , referencedColumnName = "productId" )
private Products product;
@ ManyToOne ( cascade = CascadeType. ALL )
@ JoinColumn ( name = "id" , foreignKey = @ ForeignKey ( name = "fk_billId" )) ,
@ JoinColumn ( name = "supplier" , foreignKey = @ ForeignKey ( name = "fk_billSupplier" ))
<code>@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;
</code>
@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:
< code > "@lotNumber" : "537fe03f-b261-48bb-b1dd-9215b5ad868a" ,
<code> "@lotNumber": "537fe03f-b261-48bb-b1dd-9215b5ad868a",
"lotNumber": "LOT001",
"product": {},
"bills": 7,
</code>
"@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?