EJB (Enterprise JavaBeans) 3.0 entity beans is a commonly used database persistence technology. EJB 3.0 has simplified the development of EJBs with an annotations-based API that does not require remote/local interfaces, home/local home interfaces, or deployment descriptors. Developing entity EJBs requires an application server and a relational database, and optionally a Java EE IDE to simplify the process of development. The objective of the JSR-000220 Enterprise JavaBeans 3.0 specification (http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html) is to improve the EJB architecture by reducing its complexity from the developer's point of view. EJB 3.0 has introduced some new features, which include support for metadata annotations, default values for configuration, simplified access to environment variables, simplified session and entity beans, interceptors, enhanced support for checked exceptions, and elimination of callback interfaces.
A number of books are available on EJB 3.0, but none cover EJB 3.0 on the Oracle Fusion Middleware (11g) platform. Most of the EJB 3.0 books are GlassFish server based, which has only 10percent of the application server market. Welcome to EJB 3.0 Database Persistence with Oracle Fusion Middleware 11g, a book that will teach you how to leverage EJB 3.0 persistence on Oracle Fusion Middleware 11g. Oracle Fusion Middleware 11g includes many components such as the SOA/BPM Suite, WebCenter, and Oracle Identity Management. All of these components run on Oracle Weblogic Server 11g. The main development tool (IDE) for Oracle Fusion Middleware is Oracle JDeveloper. In respect of EJB 3.0, JDeveloper provides wizard support to reverse engineer database tables as EJB 3.0 entity beans. JDeveloper 11g also provides a wizard for creating session beans. The JPA persistence provider used in JDeveloper 11g is the EclipseLink persistence provider. JDeveloper comes with its own embedded/integrated Weblogic Server instance, which makes it very easy to develop and test within the one environment. We shall be using the embedded WebLogic Server 11g in some of the chapters and the standalone WebLogic Server in others.
The objective of the book is to discuss the support of EJB 3.0 database persistence in Oracle Fusion Middleware 11g. While JDeveloper is the main Java IDE used in the book, one of the chapters leverages the Oracle Enterprise Pack for Eclipse. The book covers all aspects of EJB 3.0 database persistence including:
Creating EJB 3.0 entity beans from database tables
Creating session bean façades for entity beans
Entity beans with session beans
Creating EJB 3.0 entity relationships
Creating JSF and ADF Faces user interfaces (UIs) on top of EJB 3.0 database persistence
Using EJB 3.0 database persistence in combination with Ajax and web services
In Chapter 1, What's New in EJB 3.0, we discuss the new features in the EJB 3.0 specification, such as support for metadata annotations, default values for configuration, simplified session and entity beans, and enhanced support for checked exceptions.
In Chapter 2, Converting an EJB 2.0 Entity to an EJB, we convert an example EJB 2.0 entity bean to an EJB 3.0 entity bean. We also generate the session bean façade for the EJB 3.0 entity bean. XSLT transformation is used for converting the EJB 2.0 entity bean to an EJB 3.0 entity bean.
In Chapter 3, EclipseLink JPA Persistence Provider, we discuss the JPA framework and the EclipseLink persistence provider.
In Chapter 4, Building an EJB 3.0 Persistence Model with Oracle JDeveloper, we discuss EJB 3.0 database persistence with JDeveloper 11g, WebLogic Server 11g, and Oracle Database 10g. We create an EJB 3.0 entity bean from a database table, create a session bean façade, and finally create a JSP test client. Using the test client, we create, retrieve, and delete entity bean instances.
In Chapter 5, EJB 3.0 Persistence with Oracle Enterprise Pack for Eclipse, we discuss the same example we covered in Chapter 4, but with the Oracle Enterprise Pack for Eclipse, WebLogic Server, and the open source MySQL database, which has been acquired by Oracle.
In Chapter 6, EJB 3.0 with ADF Faces UI, we discuss using an ADF Faces client for EJB 3.0 database persistence. We create an entity bean using data input from an ADF Faces user interface (UI). Subsequently, we find an entity bean instance using data input from an ADF Faces UI.
In Chapter 7, Creating EJB 3.0 Entity Relationships, we discuss EJB 3.0 entity relationships using, as an example, three entity beans that have inter-relationships. We also discuss the significance of a fetch strategy.
In Chapter 8, EJB 3.0 Database Persistence with Ajax in the UI, we discuss EJB 3.0 database persistence in combination with Ajax in the user interface (UI). We demonstrate data validation and autocompletion with Ajax.
In Chapter 9, Using JSF with Entity Relationships, we discuss adding JSFs to EJB 3.0 database persistence to create and persist entity bean instances that have entity relationships between them.
In Chapter 10, Creating an EJB 3.0 Web Service, we create a JAX-WS Web Service from an EJB 3.0 entity bean, create a web service client, package and deploy the web service to WebLogic Server, and test the Web Service using the WebLogic console.
The book is based on Oracle JDeveloper 11g Studio Edition for Windows and Oracle WebLogic Server 11g, Windows version, which are the two main components of Oracle Fusion Middleware 11g and may be downloaded from http://www.oracle.com/technology/software/products/middleware/index.html. If you have Linux installed, the book may still be used (though the source code and samples have not been tested with Linux); just download and install the Linux versions of Oracle JDeveloper 11g and Oracle WebLogic Server 11g. Slight modifications may be required with the Linux install; for example, the directory paths on Linux would be different than the Windows directory paths used in the book. For one of the chapters, you would need to download and install Oracle Enterprise pack for Eclipse from http://www.oracle.com/tools/enterprise-eclipse-pack.html. For database, you would need to download and install Oracle Database 10g/11g from http://www.oracle.com/technology/software/products/database/index.html. For another chapter, you would need to download and install the open source MySQL 5.x database from http://www.mysql.com/downloads/mysql/. The annotations used in EJB 3.0 are a J2SE 5.0 feature; therefore, you need to install J2SE 5.0 or later.
The target audience of the book is EJB 3.0 application developers who want to learn about the practical use of EJB 3.0 database persistence with Oracle Fusion Middleware 11g. Those who are already using EJB 3.0 database persistence will learn about using EJB 3.0 database persistence with Oracle Fusion Middleware 11g. We won't be discussing the EJB 3.0 specification in much detail but you can refer - JSR-000220 (http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html) for more information. This book is suitable for professional Java EE developers. The book is also suitable for an intermediate/advanced level course in EJB 3.0. The target audience is expected to have prior, albeit beginner's, knowledge about Java EE, EJBs, EJB 3.0, JSF, ADF Faces, Ajax, Web Services, and XML. The book also requires some familiarity with WebLogic Server and Java EE IDEs, JDeveloper, and Eclipse.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "The Catalog
entity bean has properties id
and journal
".
A block of code is set as follows:
@Resources({ @Resource(name="ds1", type="javax.sql.DataSource"), @Resource(name="ds2", type="javax.sql.DataSource") })
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "In the New Gallery window, select Categories:General | XML and Items:XSL Style Sheet and click on OK".
Note
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>
, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <[email protected]>
.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Note
Downloading the example code for this book
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.