Posted by guruwons
on June 9, 2006 at 10:18 PM PDT
This year JavaOne finished and it left lots of information which will be useful for a long time. As I review it I arranged technical sessions related to EJB 3.0 and Java Persistence. Here I write brief introduction and summary of them. There are also links to those presentation files.
TS-3396 EJB 3.0 Specification (Linda DeMichiel)
Linda is JSR 220(EJB 3.0) spec lead and she covered EJB 3.0 specification here.
She started by showing what is problem in EJB 2.1 spec and went to EJB 3.0 spec goal. In short the goal is "less work for developer, more work for container".
The coverage of this session was as follows:
- Simplication of Bean Class
- Business interface
- Message driven bean
- Enviroment Access - Dependency Injection and simple lookup
- Simplication of Client View
- Transaction, Security annotations
- Lifecycle callbacks and interceptors
- Exceptions - application exceptions
There is no content for Java Persistence, see below TS-3395 for that. You can grasp the overall aspects of EJB 3.0 spec in this.
TS-1365 Extending EJB 3.0 Specification With Interceptors (Bill Burke)
Bill Burke is JSR 220 expert group member who made great progress on interceptors spec.
Interceptor is a new feature added into EJB 3.0 and it is similar to 'aspect' of AOP. He explained that interceptors can be used for cross-cutting concerns such as method profiling, exception handling, validation of parameters, custom security, and SQLException wrapping. Interceptors can be used in EJB 3.0 session beans and message-driven beans only.
You must know that interceptors can be applied to default-level, bean-level and method-level. Default-level interceptors applies to all beans in the ejb-jar module except entity beans. Bean-level interceptors applies to all methods of specific bean but method-level ones applies to only specific methods.
Interceptor also has lifecycle callback listener feature so it can be used for common callback listener class. Bill showed how to make custom injection annotation handler using interceptor.
Bill also metioned that there is extension point which is not accepted in current EJB 3.0 spec.
TS-3395 Java Persistence API (Linda DeMichiel, Mike Keith)
This session introduced the basic of Java Persistence API.
Linda explained that at the beginning expert members tried to simplify entity beans but they turned to more general approach - accepting POJO persistence technology such as Hibernate and TopLink.
The primary features of Java Persistence are POJO-based, support for inheritance and polymorphism, expanded query language than EJBQL, usable in both JavaEE and JavaSE, pluggable persistence provider.
She showed what is Entity and how to make it. EntityManager API is the central API to manipulate entities you must know. It has persist, remove, find and query methods. You should also understand the concept of Persistence Context and lifecycle of entities.
Java Persistence supports for query language more powerful than EJBQL. It added support for bulk update, delete statement and subqueries. You can also use native query - the database-specific SQL.
Java Persistence also has rich OR mapping feature - how to map your entities to relational tables. You can specify mapping through annotations or XML. But it has default rules so you don't need to specify all.
TS-9056 Java Persistence API In 60 Minutes
- Marina Vatkina, Mitesh Meswani, Pramod Gopinath
This is another Java Persistence introduction session brought by GlassFish members. This session took more practical way to explain it rather than telling lenghty spec. You can see more examples to understand JPA.
The coverage of this session is as follows:
- OR Mapping: How to map between data model and entity object model including inheritance
- EntityManager and Persistence context: explains EntityManager API, persistence context types, lifecycle of an entity
- Query: Query API, Named query, Native query, Generated SQL
- EntityManager types: Table to show differences of container-managed, application-managed and JTA, resource-local EntityManager
- Packaging: Persistence Unit, persistence.xml descriptor
It also points out some important things which you should know - pragmatically useful.
Marina Vatkina's Blog here
TS-1887 The Java Persistence API in the Web Tier
- Linda DeMichiel, Gavin King, Craig McClanahan
The great masters joined together for this session! I missed this session unfortunately.
This session addresses chiefly how to use Java Persistence in web tier like Servlet, JSF. It starts by explaining the basic of Java Persistence API and JSF and covers follwings:
- Threading model and injections - do not inject EntityManager on shared objects like Servlet...
- Transaction and Java Persistence - how to demarcate tx for persistence operations...
- Extended Persistence Contexts - how to maintain managed entities for conversation...
Do not miss this session if you want to use Java Persistence in web-tier.
TS-1969 Blueprints for Using the Simplified Javaâ„¢ EE 5 Programming Model
- Inderjeet Singh
This session talked real practice of Java EE 5 which is not covered in the spec.
This covered as followings:
- Annotation vs XML descriptor - which one is better and suitable for each situation.
- Dependency - injection
This addressed two types of metadata - structural one and runtime one. Structural metadata are like @Stateless, @Resource, @EJB, @PostConstruct which do not change often. Runtime metadata are like security @RolesAllowed which change at runtime configuration. Because runtime metadata can change at runtime, you'd better specify it at XML descriptor.
Inderjeet Singh's Blog here
TS-3616 Building EJB 3.0 Based Applications
- Mike Keith, Merrick Schincariol
This is practical EJB 3.0 and Java Persistence session presented by Oracle members.
They showed how to build and package EJB 3.0 sample AirLine reservation application. Most of contents was about 'entity packaging'.
- Persistence unit and persistence.xml
- Entity packaging in EJB JAR file
- Entity packaging in a separate JAR file
- Packaging as a persistence library
TS-1624 Writing Performant EJB Beans in the Java EE 5 Using Annotations
(Scott Oaks, Eileen Loh, Raul Biswas)
GlassFish performance teams addressed how new EJB 3.0 features affect performance. There are many interesting benchmark charts and tips here which you should not miss.
There are two types of performance - deployment and runtime. They started by questioning followings.
- How deployment/runtime annotations affect performance?
- Will annotation makes deployment fast or slow?
This session talked following aspects.
- Local vs. Remote interface
- Dependency injection vs. Dynamic lookup
- interceptors overhead
- Container-managed tx vs. Bean-managed tx
- Transaction attributes
- FetchType - LAZY vs. EAGER
- Inhertiance strategy - Single table vs. Joined subclass
- FlushMode - AUTO vs. COMMIT
- Optimistic locking, Isolation Level
- Extended Persistenc Context vs. Transaction-scoped Persistence Context
- Secondary Tables
- Find method vs. Join query
- EJB 2.1 vs. EJB 3.0
Scott said that these result is still early and need more investigation.
He also mentioned that developer productivity and mantainability is also important performance factors.
Scott Oaks' Blog here