Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
In Part 1 of this series, I discussed the annotation-driven POJO (plain-old Java objects) programming model in Enterprise JavaBeans 3.0 (EJB). I explained how to develop POJO services, how to deliver container services to POJOs, and how to assemble applications using dependency injection. Those POJO services are typically used to encapsulate an application's business logic. Behind the business logic, most of today's enterprise applications have a data-model layer backed by a high-performance relational database.
In Part 2, I discuss how EJB 3.0 entity beans leverage POJO and annotations to greatly simplify your data model and its persistence-to-backend relational databases. Before we get into the details of EJB 3.0 entity beans, let's first discuss why data modeling and persistence are such big challenges in enterprise Java.
Inside the JVM, all data is modeled and encapsulated in a tree of classes and objects. However, in the backend relational database, the data is modeled as relational tables, which are interlinked via shared key fields. Those two different views of the same data represent a difficult challenge for enterprise Java developers: when you must save or retrieve data to or from the persistence datastore, you must convert the data back and forth between the object and relational representations, a process called object-relational mapping (ORM). In Java EE (Java Enterprise Edition, previously called J2EE), you can complete object-relational mapping in two ways:
| Object database |
|---|
| An object database stores, retrieves, and searches objects directly in the datastore, which could be a good fit for Java applications since no ORM is needed. Unfortunately, today's object database technology remains relatively immature and slow compared with relational databases. You could reasonably say that a good ORM framework essentially provides an object database interface for a relational database. It gives you the best of both worlds. |
In this article, I focus on the automated framework approach for ORM in enterprise Java applications. In the next section, I cover several popular ORM frameworks and the key innovations in EJB 3.0.
The EJB entity bean is the "official" ORM solution in Java EE. However, in EJB 1.x and 2.x, the entity beans are notoriously difficult to use for two reasons:
In short, the EJB 1.x and 2.x entity bean is a poorly designed ORM framework that addresses the needs of neither the Java
object data model nor the relational table data model. Unsatisfied with EJB 1.x and 2.x entity beans, developers look to other
solutions for ORM. In the real world, the open source Hibernate (developed by JBoss) and Oracle's TopLink are the two most
successful Java ORM frameworks. Both Hibernate and TopLink are POJO-based: they do not rely on any predefined component model.
Instead, they take POJO data objects (in simple JavaBeans style) and automatically decipher how to map them, as well as the
relationships among them, to relational databases. Usually one JavaBeans class maps to one database table, and relationships
between the classes are mapped via foreign key fields in the tables. You can specify ORM metadata, such as the JavaBeans class's
corresponding table name and the property's corresponding column name, in a simple and intuitive XML configuration file. You
operate on those POJOs (e.g., saving, retrieving, and searching) via a utility class in the framework (e.g., the Session class in Hibernate).
The EJB 3.0 entity bean builds upon the ideas and success of Hibernate and TopLink. It provides a standard POJO ORM framework for Java EE. In addition, EJB 3.0 has two crucial innovations over existing POJO persistence solutions:
Now, let's check out how EJB 3.0 accomplishes POJO ORM via several simple examples.
| Subject | Replies |
Last post
|
|
By Anonymous |
2 |
10/05/06 08:10 AM
by Anonymous |
|
By Anonymous |
2 |
10/05/06 03:37 AM
by Anonymous |
|
By Anonymous |
7 |
10/04/06 10:14 AM
by Anonymous |
|
By Dahrmaraja |
0 |
10/04/06 07:12 AM
by Anonymous |
|
By JavaWorld
|
1 |
10/03/06 01:44 PM
by Anonymous |
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq