Pinaki, first thanks for you attention!

Second, we are converting an old hibernate project and that one used this design.
OpenJPA (or for that matter anyone other than the designer) has no way to
know that private Integer cdProduto;
refers to the primary key of the field
private Produto produto;//read only
So, what does these tags:

   @ManyToOne
@JoinColumn(name = "cd_produto", referencedColumnName="cd_produto", insertable = false, updatable = false)
means?

In that case it will save just the Item table, but not the nested Produto table.
You have tell that to OpenJPA.

So what you can do (if the design insist on a arguably erroneous domain
model for all the wrong reasons)
I don't think it is "erroneous domain model"! In IT we may find several use cases and different situations. And this project isn't different.

 to maintain referential integrity is:

public Item(....,Produto p) {
  this.cdProduto = p.getCdProduto();
  this.produto = p;
}

I thought I could make the app work with some adjusts using openjpa!
Gilberto

Reply via email to