Basic terms Flashcards
Specification - framework
Specification of the frameworks - interfaces
List of requirements
Any frameworks implement the same specification can be replaced one by another.
- One or more specification that explains the details and defines functionalities.
- Reference Implementation for the specification.
- Compatibility Test Kit.
Enterprise application?
- Deal with huge data.
- Consistent change, and complexity.
- Must be robust.
- Highly available, scalable, and secure.
- Develop business-to-business communication.
- Multiple programming languages.
- Different protocols.
- Different locations.
- Java Enterprise Edition, launched 1999
- Java EE, is now simpler, easier, more portable.
Problems/inconveniences of using JDBC?
- Have to know SQL to use JDBC
- How and where to store object attributes to tables - mapping object to table
- Runtime problem - syntax checking in runtime
Advantages of using JDBC?
- Prepared statement
- Fast - lowest level of programming
- Not depends on type of DB
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?
- Contain business data.
- Process data through triggers & SP.
- Data is stored in tables of rows and columns.
- Primary keys identify data.
- Foreign keys & joins establish relations.
- Data exists even if the RDMS is not running.
How is data handled in Java?
- Stores business data in attributes (either primitive types or instances of objects).
- Manipulates data through methods using objects.
- Data exists only if the JVM is running.
- Inheritance, interfaces, enumerations, abstract classes, …
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
- Objects that live shortly in memory, and persistently in a database.
- Mapped to database.
- Can be concrete or abstract.
- Support inheritance, associations, and so on.
- Manageable by JPA.
- Can be queried using JPQL.
- Follows a defined life cycle.
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)