Prev Next

Hibernate / Hibernate interview questions

Difference between save and persist.

Save()

  1. Returns generated Id after saving. The return type is serializable.
  2. Saves the value to DB immediately and keeps track of the entity until the end of the session(I have tried to change the entity values outside of the transaction, it does not show any effect when session commits)
  3. Does not save the changes to the db outside of the transaction.
  4. Assigns the generated id to the entity you are persisting
  5. Session.save() for a detached object will create a new row in the table.

Persist()

  1. Does not returns generated Id after saving. Its void return type.
  2. Saves the value to DB immediately and keeps track of the entity until the end of the session.(I have tried to change the entity values outside of the transaction, it does not show any effect when session commits)
  3. Does not save the changes to the db outside of the transaction.
  4. Assigns the generated id to the entity you are persisting
  5. session.persist() for a detached object will throw PersistentObjectException as it is not allowed.

It's right time to invest in Cryptocurrencies Dogecoin! Earn free bitcoins up to $250 now by signing up.

Earn bitcoins upto $250 (free), invest in other Cryptocurrencies when you signup with blockfi. Use the referral link: Signup now and earn!

Using BlockFi, don't just buy crypto - start earning on it. Open an interest account with up to 8.6% APY, trade currencies, or borrow money without selling your assets.


Join CoinBase! We'll both receive $10 in free Bitcoin when they buy or sell their first $100 on Coinbase! Available in India also. Use the referral Join coinbase!


Invest now!!! Get Free equity stock (US, UK only)!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.


Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

In a Parent-child relationship, how will you only access the columns from parent? Difference between @NotNull, @NotEmpty and @NotBlank. Different between session.get() and session.load() in Java. Difference between save and persist. What is HQL (Hibernate Query Language)? Difference between Hibernate createCriteria, createQuery, createSQLQuery. @UniqueConstraint and @Column Unique attribute. 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