I have two entities LR.java
and LI.java
. One request may have more than one items on it.
After the execution of this method the lR is always null inside the item table. What I am doing wrong here? Any suggestions
I have two entities LR.java
and LI.java
. One request may have more than one items on it.
After the execution of this method the lR is always null inside the item table. What I am doing wrong here? Any suggestions
You defined a bidirectional "manytoone" association, so it's develepoer's responsability to keep consistent both sides of the association (that is: loanRequest and loanItems).
You should set the field loanRequest of the Loanitem entity to point to "right" LoanRequest. Do you so in the addLoanItem ?
Beside, unless you really need to "navigate" from one entity to the other and backward I suggest you to use unidirectional association, they are far more manageable and less prone to errors like this.
Anyway, @XtremeBaumer is right, constructor of LoanItem should be empty.