database connection - hibernate.properties or hibernate.cfg.xml
class mapping setup
Session Factory Object
Configuration Object is used to create sessionFactory which in turn configures hibernate for the application using the supplied configuration file and allows for a session object to be instantiated.
ThreadSafe and heavyweight (usually created during app start up)
one database one sessionFactory
Session Object
Session is used to get a physical connection with a database.
Lightweight - designed to be instantiated each time an interaction is needed with the database.
Transaction Object
A Transaction represents a unit of work with the database and most of the RDBMS supports transaction functionality. Transactions in Hibernate are handled by an underlying transaction manager and transaction (from JDBC or JTA).
Query Object
Query objects use SQL or Hibernate Query Language (HQL) string to retrieve data from the database and create objects
Criteria Object
create and execute object oriented criteria queries to retrieve objects.
Configuration
Screen Shot 2020-11-20 at 10.27.55 PM
Session
The session objects should not be kept open for a long time because they are not usually thread safe and they should be created and destroyed them as needed.
State
transient
A new instance of a persistent class, which is not associated with a Session and has no representation in the database and no identifier value is considered transient by Hibernate.
persistent
You can make a transient instance persistent by associating it with a Session. A persistent instance has a representation in the database, an identifier value and is associated with a Session.
detached
Once we close the Hibernate Session, the persistent instance will become a detached instance.