Hibernate (Java) Interview Questions and Answers

Hibernate Questions and Answers:

1 :: What are the ORM level?

The ORM levels are:

* Pure relational (stored procedure.)
* Light objects mapping (JDBC)
* Medium object mapping
* Full object Mapping (composition,inheritance, polymorphism, persistence by reachability)
3/5 Rating (2 votes)
Is This Answer Correct?    19 Yes 5 No
Place Your Answer

2 :: What does ORM consists of?

An ORM solution consists of the followig four pieces:

* API for performing basic CRUD operations
* API to express queries refering to classes
* Facilities to specify metadata
* Optimization facilities : dirty checking,lazy associations fetching
2/5 Rating (1 vote)
Is This Answer Correct?    16 Yes 4 No
Place Your Answer

3 :: What are the general considerations or best practices for defining your Hibernate persistent classes?

1.You must have a default no-argument constructor for your persistent classes and there should be getXXX() (i.e accessor/getter) and setXXX( i.e. mutator/setter) methods for all your persistable instance variables.

2.You should implement the equals() and hashCode() methods based on your business key and it is important not to use the id field in your equals() and hashCode() definition if the id field is a surrogate key (i.e. Hibernate managed identifier). This is because the Hibernate only generates and sets the field when saving the object.


3. It is recommended to implement the Serializable interface. This is potentially useful if you want to migrate around a multi-processor cluster.

4.The persistent class should not be final because if it is final then lazy loading cannot be used by creating proxy objects.

5.Use XDoclet tags for generating your *.hbm.xml files or Annotations (JDK 1.5 onwards), which are less verbose than *.hbm.xml files.
2.5/5 Rating (2 votes)
Is This Answer Correct?    11 Yes 1 No
Place Your Answer

4 :: How would you reatach detached objects to a session when the same object has already been loaded into the session?

You can use the session.merge() method call.
5/5 Rating (1 vote)
Is This Answer Correct?    9 Yes 1 No
Place Your Answer

5 :: What is the difference between the session.update() method and the session.lock() method?

Both of these methods and saveOrUpdate() method are intended for reattaching a detached object. The session.lock() method simply reattaches the object to the session without checking or updating the database on the assumption that the database in sync with the detached object. It is the best practice to use either session.update(..) or session.saveOrUpdate(). Use session.lock() only if you are absolutely sure that the detached object is in sync with your detached object or if it does not matter because you will be overwriting all the columns that would have changed later on within the same transaction.

Note: When you reattach detached objects you need to make sure that the dependent objects are reatched as well.
0/5 Rating (0 vote)
Is This Answer Correct?    4 Yes 6 No
Place Your Answer

Rate This Category:
3.7/5 Rating (3 votes)
Place Your Question



Top: Hibernate (Java) Interview Questions and Answers
Hibernate (Java) Interview Questions and Answers

Top Frequently Asked Hibernate Question
Frequently Asked Hibernate Job Interview Question


Top Frequently opened Java Programing Job Interview categories
Most popular Java Programing Job Interview categories

Comments About Hibernate (Java) Interview Questions and Answers

Share your valuable opinions, ideas and suggestions about Hibernate (Java) Interview Questions and Answers
While placing your comment your email address is required but won't be published any where else; Personal information will be kept confidential; we do not sell or release our respective visitors private information.
  1. Webmaster 23rd of May 2012

    Webmaster Said

    Tell us what you feel about Hibernate (Java) Interview Questions and Answers
    All comments will be published after review. No login or registration is required to post a comment on Hibernate (Java) Interview Questions and Answers We offer and invite you to submit your valuable comment now; Please be respectful of others when commenting. Insulting others, self-promotional comments, website promotional comments, marketing stuff, SEO Techniques, SMS-style content and off-topic comments will not be approved at this information portal.
    So start sharing your thoughts regarding Hibernate (Java) Interview Questions and Answers
    Thank you.

Leave a Comment

Leave a Comment
  1.  Enter This Verification Code  Regenerate Verification Code  



Your reply will be added to the comment above (Below any other replies to this comment) -

Top Comments About: Hibernate (Java) Interview Questions and Answers
Comments on Hibernate (Java) Interview Questions and Answers

 
Top of Link batk to Hibernate (Java) Interview Questions and Answers
Link batk to Hibernate (Java) Interview Questions and Answers