Tuesday, September 8, 2009

EJB and Hibernate notes

EJB

*Session Bean -- stateful and stateless
* Entity Bean
* Message Driven Bean

EJB Architecture
* A remote interface -- a client interacts with it
* A home interface -- used for creating objects and for declaring business methods
* A bean object -- an object which actually performs business logi cna EJB-specific operations
* A deployment descriptor -- ( an XML file containing all information required for maintaining the EJB) or a set of deployment desciptor.
* A primary key class - is only entity bean specific.

[http://www.comptechdoc.org/docs/kanti/ejb/ejbarchitecture.html]

Entity Bean
* represent data in the database.
* most of the time container takes care of the persistence, transaction and access control while developer can focus on the bean logic.

Container Managed Bean
* all the logic for synchronizing the bean's state with the database is handled automatically by the container.
* developer does not need to write any data access logic.
* container takes care of persistence.

Bean Managed Persistence
* developer can handle the persistence if needed.
* developer can handle the data source.

ORM
ORM is the automated persistence of objects in Java application to the tables in a relational database.

Hibernate
*persistence framework
*pure java object relational mapping.
*maps POJO to relational database tables.
*relieves developr from persistence related programming task.
*hibernate.cfg.xml - hibernate configuration file
* *.hbm.xml -- mapping file, tells which tables and columns to use to load and store objects.
*hibernate.properties - resource bundle

session
*light-weight and non-threadsafe object
*sessionFacotry creates session and then closes it once work is done.

Hibernate Persistent Class (Hibernate Bean)
* just another regular bean class.
* setters and getters, no arg constructor
* can override the equals() and hashcode() methods.
* the persistent class should not be final.

No comments: