Help the world stop coronavirus! Stay home!

Prev Next

Hibernate / Hibernate interview questions

Explain transaction management in hibernate.

In hibernate framework, we have Transaction interface that defines the unit of work. It maintains abstraction from the transaction implementation (JTA,JDBC).

A transaction is associated with Session and instantiated by calling session.beginTransaction().

The transaction interfaces defines the below methods.

  • void begin() starts a new transaction.
  • void commit() ends the unit of work unless we are in FlushMode.NEVER.
  • void rollback() forces this transaction to rollback.
  • void setTimeout(int seconds) it sets a transaction timeout for any transaction started by a subsequent call to begin on this instance.
  • boolean isAlive() checks if the transaction is still alive.
  • void registerSynchronization(Synchronization s) registers a user synchronization callback for this transaction.
  • boolean wasCommited() checks if the transaction is commited successfully.
  • boolean wasRolledBack() checks if the transaction is rolledback successfully.

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

What is HQL (Hibernate Query Language)? @UniqueConstraint and @Column Unique attribute. Difference between @NotNull, @NotEmpty and @NotBlank. Different between session.get() and session.load() in Java. Difference between save and persist. In a Parent-child relationship, how will you only access the columns from parent? Difference between Hibernate createCriteria, createQuery, createSQLQuery. What are the most common methods of Hibernate configuration? What is ORM ? What is hibernate? What does ORM consists of ? @Repository @Embeddable @Service @Controller Differentiate JPA and hibernate. What are the ORM levels ? Why do you need ORM tools like hibernate? core interfaces of Hibernate. Is SessionFactory a thread-safe object? What role does the SessionFactory interface play in Hibernate? Is Hibernate Session a thread-safe object? What are the different states of object in hibernate? How to make a immutable class in hibernate? Different types of association in hibernate. Is it possible to perform collection mapping with One-to-One and Many-to-One? What is lazy loading in hibernate? What is the difference between merge and update ? How do you define sequence generated primary key in hibernate? What are the Collection types in Hibernate ? What is Hibernate proxy? What are Callback interfaces? What are the types of inheritance models in Hibernate? Benefits of hibernate over JDBC? Session Interface. SessionFactory Interface. Configuration Interface. Transaction Interface. Query and Criteria Interface. What are Callback interfaces? What is POJO? Detached Criteria Advantages of Detached criteria. Explain N+1 SELECT problem in Hibernate. List the strategies to eliminate the N+1 SELECT problem in Hibernate. Explain high level architecture of Hibernate framework. How do we see hibernate generated SQL on console? Hibernate: Can a Entity Class be declared final? How to call stored procedure in Hibernate? Explain transaction management in hibernate. Difference between fetch mode and fetch type in Hibernate. What is the default fetch mode in Hibernate? What is the difference between FetchType.LAZY and FetchType.EAGER in Java Persistence API? Difference between using a @OneToMany and @ElementCollection annotation in Hibernate. Explain the features introduced in Hibernate 5. Which throws Exception when no row found: session.load vs session.get. Difference between criteria and HQL In hibernate.
Show more question and Answers...

Hibernate interview questions II

Comments & Discussions