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();
Which line of code allows Hibernate to understand how to access the underlying database?
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?
- Create a SessionFactory.
- Based on this SessionFactory, create a session.
- Begin the transaction.
- save or update the object.
- Commit the transaction.