In a relational database in a one-to-many relationship, a row in table X can have  more than one matching row in table Y.

In Object oriented programming, one instance of entity refers to multiple instances of another entity in the  relation called one-to-many relation.

In this tutorial used the relationship between Engineering Branch and Students. In an Engineering college each Branch have many Students.

one-to-many Tables structure in Database : mapping : mapping :


Cascade :

  • Whenever rows in the parent table manipulated (inserted, updated, deleted) the respective rows of the child table with a matching key column will be manipulated as well. This is called Cascade in Database.
  • JPA translates entity state transitions to database DML statements.

@JoinColumn :

  • @JoinColumn Specifies a column for joining an entity association or element collection. The annotation MARKDOWN_HASHf6fe5d6d260954e3d74370aaeb356271MARKDOWN_HASH indicates that this entity is the owner of the relationship. That is the corresponding table has a column with a foreign key to the referenced table.
To Understand Cascade and @JoinColumn mapping in entity associations see :
Key points to understand associations Testing the above mapping :

Console Output :

Download Application – (14 KB)