An Owner entity has a @ManyToOne - @OneToMany relationship with the teacher entity. When I annotate each like this
@Entity
public class Product {
... 
@ManyToOne(cascade = MERGE)
private final Owner owner;
On the other side, in the Owner Class,
@Entity 
public class Owner {
...
@OneToMany(mappedBy = "owner", cascade = MERGE)
private final List<Product> products;
What happens now is that "owner" in the line mappedBy = "owner" turns red. Hovering over it, I get the error that the owner attribute cannot be found.
The error: Cannot find inverse attribute
The solution was simply to remove the final keyword in the attribute owner in the Product class.
It becomes private Owner owner and the error disappears. I don't understand why adding the keyword final causes this problem.
Why does this happen? Is there a workaround? Can I still make the owner attribute final?
The main idea from the getgo was to make the product class immutable. While this is a challenge, I've managed to find a workaround for most things, but I didn't know how to fix this problem.