Added by on 2013-07-05

What are the uses of @Entity and @Id tag?
@Entity annotation indicates that the class should persist to the database.
@Id annotation represents a unique primary key

How do you tell Hibernate which classes are to be persisted?
AnnotationConfiguration conf = new AnnotationConfiguration();
conf.addAnnotatedClass(Employee.class)

Which line of code allows Hibernate to understand how to access the underlying database?

config.configure("hibernate.cfg.xml");

Which object connects to the underlying database and generates the various tables?

new SchemaExcport(conf).create(true, true);

What are the steps involved in saving an instance?

  1. Create a SessionFactory.
  2. Based on this SessionFactory, create a session.
  3. Begin the transaction.
  4. save or update the object.
  5. Commit the transaction.

Category:

Hibernate

Tags:

, ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*