The mappedBy
attribute is only necessary for a bidirectional
relationship, this element can be omitted on the annotation. It is used on the source entity to point back to a field on the target entity that defines the relationship (contains @JoinColumn).
The @JoinColumn
annotation should be placed upon the billSimpleEntry
field to define the column that should be used to join the two tables. In the case of a OneToOne
the following applies:
If the join is for a OneToOne or ManyToOne mapping using a foreign key mapping strategy, the foreign key column is in the table of the source entity or embeddable.
Here is a code example:
@OneToOne(cascade=CascadeType.ALL,fetch = FetchType.EAGER)
@JoinColumn(name="id")
private BillSimpleEntry billSimpleEntry;
Also, if the Bill
will contain the SimpleBillEntry
field the BILL
table should contain a foreign key to the billsimpleentry
table.