Logo F2FInterview

Hibernate Interview Questions

Q   |   QA

Use update() if you are sure that the session does not contain an already persistent instance with the same identifier, and merge() if you want to merge your modifications at any time without consideration of the state of the session.

Using <generator> tag.


<id column=”USER_ID” name=”id” type=”java.lang.Long”>

    <generator class=”sequence”>

       <param name=”table”>SEQUENCE_NAME</param>



cascade – enable operations to cascade to child entities.
inverse – mark this collection as the “inverse” end of a bidirectional association.
Essentially “inverse” indicates which end of a relationship should be ignored, so when persisting a parent who has a collection of children, should you ask the parent for its list of children, or ask the children who the parents are.

It informs hibernate to ignore that end of the relationship. If the one–to–many was marked as inverse, hibernate would create a child–>parent relationship (child.getParent). If the one–to–many was marked as non–inverse then a child–>parent relationship would be created.

  1. Table per concrete class.
  2. Table per class hierarchy.
  3. Table per subclass.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: