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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.