What are the two locking strategies in Hibernate?

There are two popular locking strategies that can be used in Hibernate: Optimistic: In Optimistic locking we assume that multiple

What is the use of version number in Hibernate?

Version number is used in optimistic locking in Hibernate. When a transaction modifies an object, it increments its version. Based

What is the use of session.lock() method in Hibernate?

Session.lock() is a deprecated method in Hibernate. We should not use it. Instead we should call buildLockRequest(LockMode).lock(entityName, object) method in

What inheritance mapping strategies are supported by Hibernate?

Hibernate supports following inheritance mapping strategies between classes and tables: Table per class hierarchy: In case of multiple types of

How can we check if an Object is in Persistent, Detached or Transient state in Hibernate?

We can use following methods to check the state of an object in Hibernate: Persistent State: If call to EntityManager.contains(object)

What is ‘the inverse side of association’ in a mapping?

Let us consider an example in which a customer can have multiple orders and for every order there has to

What is the difference between load() and get() method in Hibernate?

In Hibernate, load() and get() methods are quite similar in functionality. The main difference is that load() method will throw

When should we use get() method or load() method in Hibernate?

As a thumb rule we can follow these guidelines:

What is a derived property in Hibernate?

In Hibernate, a derived property is not mapped to any column of a database table. A derived property is computed