I'm having hard time understanding the following piece of documentation what does the comment
We need to duplicate the physical
means ?
What's the point of using insertable=false, updatable=false ?
Please, Can you help ?
To map a bidirectional one to many, with the one-to-many side as the owning side, you have to remove the mappedBy element and set the many to one @JoinColumn as insertable and updatable to false. This solution is not optimized and will produce some additional UPDATE statements.
@Entity
public class Troop {
@OneToMany
@JoinColumn(name="troop_fk") //we need to duplicate the physical information
public Set<Soldier> getSoldiers() {
...
}
@Entity
public class Soldier {
@ManyToOne
@JoinColumn(name="troop_fk", insertable=false, updatable=false)
public Troop getTroop() {
...
}
troop_fk
referenced in another@Column
on theSoldier
class? – Dean Clark