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

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

How can we check is a collection is initialized or not under Lazy Initialization strategy?

Hibernate provides two convenient methods, Hibernate.initialize() and Hibernate.isInitialized() to check whether a collection is initialized or not. By using Hibernate.initialize()

What are the different strategies for cache mapping in Hibernate?

Hibernate provides following strategies for cache mapping: Read only: If an application requires caching only for read but not for

What is the difference between a Set and a Bag in Hibernate?

A Bag in Hibernate is an unordered collection. It can have duplicate elements. When we persist an object in a

How can we monitor the performance of Hibernate in an application?

We can use following ways to monitor Hibernate performance: Monitoring SessionFactory: Since there is one SessionFactory in an application, we

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