What is the role of mappedBy in JPA or inverse=“true” in Hibernate?

The reason for "inverse" is that in a database there is always one side controlling a relation (e.g. the FK side), while in your bidirectional domain model mapping you can make changes to both the one-to-many side (add/remove children) and the child side (setting the parent). That's why both sides need to stay in sync.

Hibernate can't automatically enforce the synchronism constraint, so it's the developer responsibility to make it happen. The only thing Hibernate can do is to observe one side only (in order to translate state transitions into SQL queries).

Therefore it's a good habit to provide add/removeChild like utility methods:

@Entity
public class Parent {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", orphanRemoval = true)
    private List children = new ArrayList();

    public List getChildren() {
        return children;
    }

    public void addChild(Child child) {
        children.add(child);
        child.setParent(this);
    }

    public void removeChild(Child child) {
        children.remove(child);
        child.setParent(null);
    }
}