Specification - framework
Specification of the frameworks - interfaces
List of requirements
Any frameworks implement the same specification can be replaced one by another.
Enterprise application?
Problems/inconveniences of using JDBC?
Advantages of using JDBC?
JavaEE
Is the collection of specs to solve Enterprise problem
JEE Umbrella JSR, Platform Edition Specification.
CTK - Compatibility Test Kit.
set of test each implementation has to pass to qualify to named an implementation of the spec.
How is data handled in RDBM?
How is data handled in Java?
Java Persistence
Persistence is to keep the data alive even after the program that is running it is terminated.
How can you achieve Persistence in Java
•Serialization •File •XML •Database - JDBC - ORM - JPA - Spring Persistence
Java Persistence API
As a specification, the Java Persistence API is concerned with persistence, which loosely means any mechanism by which Java objects outlive the application process that created them.
The JPA specification lets you define which objects should be persisted, and how those objects should be persisted in your Java applications.
By itself, JPA is not a tool or framework; rather, it defines a set of concepts that can be implemented by any tool or framework.
JPA components
List of APIs •ORM •Entity Manager API (CRUD) operations. •JPQL (Java Persistence Query Language) OOQL. •Transactions, JTA & non-JTA •Callbacks and listeners. •Optional XML mapping Built on top of JDBC, so you are still eventually using JDBC, but you don’t worry about it.
Entity
How to implement Entity?
•An annotated Java Class (or an XML descriptor).
@Entity
Must:
•Have id @Id @GeneratedValue
•Have a default constructor.
•Not final.
•Implement Serializable when it has to be passed as detached objects.
Entity Lifecycle
Entity is a POJO.
When managed by Entity Manager (attached)
•it has a persistence identity.
•It has a synchronized state with a database.
When not managed they are detached
•Used as regular java classes (garbage collected)
Operations on entity: •Persist (Create) •Update (Update) •Delete (Delete) •Load (Select)
ORM – Object Relational Mapping
Entity Manager