You can easily install the schema and connect to the database, and then create an application and projects in which to organize your application files. Then work in JDeveloper's IDE to create the business services for your application.
Install the Schema: Download the schema zip file from OTN and install it. The cue cards use tables that are part of the Fusion Order Demo (FOD) schema.
Create a New Application and Project: Use the Create Application wizard to create an application and projects for the EJB Components model and the user interface portions of the application.
Create a Database Connection: Use the Create Database Connection dialog to create a connection to the schema.
Create Entities from Tables: Use the Create Entities from Tables wizard to create JPA entities.
Create an EJB Diagram: Use the Create EJB Diagram dialog then drag and drop tables onto the diagram.
Create a Session Bean: Use the Component Palette to launch the Create Session Bean wizard.
Add a Named Query: Double-click the entity in the diagram to open it in the source editor and add sample code.
Create and Run a Sample Java Client: Use the Create Sample Java Client dialog to create the file, and then edit it in the source editor.
Run the Java Service Outside the Java EE Container: Use the Create Persistence Unit dialog opened from the Create Java Service Facade wizard to create a persistence unit that runs outside the Java EE container.
Expose the EJB as a Data Control: In the Application Navigator, create the data control from
The steps and examples in the cue cards are based on tables that are part of the Fusion Order Demo (FOD) schema. This schema is also used as the database for the sample application that ships with Oracle JDeveloper 11g, as well as other collateral in this release. It will be convenient to have this schema installed, and you only need to do it once. If you have already installed the FOD schema, you can skip this step and go directly to the next card. [ tell me more...]
jdeveloper.home, and all the
db.*settings). Keep all other properties set to their default values. The demo user must be named FOD.
/jdeveloperdirectory where you have JDeveloper installed, for example,
After running the Ant task, you should see a build successful message in the JDeveloper Log window. [ tell me more...]
The JDeveloper application is the highest level in the organizational structure. It stores information about the objects you are working with, while you are creating your application. It keeps track of your projects and the environment settings while you are developing. [ tell me more...]
OrdersApplicationto follow along with the example.
Application templates provide you with a quick way to create the project structure for standard applications with the appropriate combination of technologies already specified. The new application created from the template appears in the Application Navigator already partitioned into tiered projects, with the associated technology scopes set in each project. [ tell me more...]
UserInterfaceas the name for the view and controller project, and click Next twice.
EJBModelas the name for the model project, and click Finish .
In the Application Navigator, projects are displayed as the top level in the hierarchy. The Application Navigator should now look like this: [ tell me more...]
You can connect to any database for which you have connection details, or install the sample schema used in the cue card examples and then establish a connection to it. If you installed the sample schema, you will be able to follow the steps in the cue cards exactly as written. If you work with your own database, you can supply your own values as needed. [ tell me more...]
FODfor the connection name and
fodfor the username.
The database connection is now included as a resource for your application. [ tell me more...]
Enterprise JavaBeans (EJB) technology is the server-side component architecture for Java Platform, Enterprise Edition (Java EE) that encapsulates business logic. EJB technology enables rapid and simplified development of distributed, transactional, secure and portable applications based on Java technology. [ tell me more...]
The database connection you made earlier is available as an application resource, and can be selected from the Connection dropdown list, if it is not selected by default. [ tell me more...]
In the wizard page, you can click Query to query the database and list all the available tables. From the list of tables, you can select the tables you want to work with in your application. In this example, you will select the ORDERS and ORDER_ITEMS tables. [ tell me more...]
In the Application Navigator, one Java file is created for Orders and one for OrderItems, in the Application Sources node. These are the JPA entities that were created from the Orders and Order_Items tables. [ tell me more...]
You can model Enterprise JavaBeans on a diagram to visualize a design as you develop it. Whenever a bean is modeled, the underlying implementation files are also created. [ tell me more...]
EJB Diagramas the diagram name, and accept the default package name. Then click OK.
The EJB diagram created with the dialog is opened in the editor area. [ tell me more...]
The diagram displays the EJB components that correspond to the reverse engineering action you performed on Orders and OrderItems. The Orders and OrderItems entities are displayed along with a representation of their relationship. [ tell me more...]
A session facade presents client objects with a unified interface to the underlying EJBs. The client interacts only with the facade, which resides on the server and invokes the appropriate EJB methods. As a result, dependencies and communication between clients and EJBs are reduced. If you are performing remote access without a session facade, numerous remote calls are needed for the clients to access EJB 3.0 entities directly over the network. This results in a large amount of network traffic that negatively affects performance. In addition, without a facade, the client depends directly on the implementation of the business objects, so that if the interface of an EJB changes, client objects have to be changed as well. [ tell me more...]
FODFacadeas the EJB name.
Clients access an EJB component through its interface. The remote interface is used for client applications that run in a separate virtual machine, such as Java clients. The local interface is used for client applications that run in the same virtual machine, such as web clients. [ tell me more...]
The EJB diagram now includes the session bean you just created. [ tell me more...]
Named queries enable you to define queries at design time and then use them at run time. A
NamedQuery metadata statement has been created by default in the
OrderItems.java entity, by the Create Entities from Tables wizard. It retrieves all rows from the OrderItems table: [
tell me more...]
Features available to you in the source editor include: [ tell me more...]
@annotationsand add a query to the class that retrieves order items by
OrderItems.javaclass. You should see a
Successful compilationmessage in the Messages Log window.
In the Specify Session Facade Options dialog, you can expose the new method by selecting it from the available nodes. All entities in this project appear as nodes in the tree. [ tell me more...]
JDeveloper includes a sample Java client utility you can use to test an EJB. To generate a sample Java client, you will right-click a session bean in the Application Navigator and choose New Sample Java Client . [ tell me more...]
To test your business services, you will right-click the session bean in the Application Navigator and choose R un . JDeveloper automatically starts Integrated WebLogic Server, if it is not already running. Then JDeveloper compiles and deploys the application to Integrated WebLogic Server: [ tell me more...]
forloop corresponding to the
getOrderItemsFindAllmethod, and comment out the
forloop corresponding to the
getOrdersFindAllmethod, to see only the results of the
To better visualize the result of the
getOrderItemsFindByQuantity method, you can edit the
FODFacadeClient.java class, and comment out: [
tell me more...]
After editing the code and running the sample client again, the Log window should display only the returned rows retrieved by the
'3' clause (that is, order items with quantity greater than 3): [
tell me more...]
A persistence unit can be configured to run inside or outside the container. In EJB 3.0, you can run entities in a pure Java SE environment, without using an application server. One reason you might do this is to create a simple Java SE test bed (using JUnit, perhaps) to test your entity behavior without the overhead of deploying/executing in an application server. Another reason would be to run a Swing application locally. [ tell me more...]
outsideas the persistence unit name. Confirm that JDBC Connection is selected and the database connection you created is shown in the dropdown list (for example, FOD) and click Next . Then click Finish .
From within the Create Java Service Facade wizard, you can create a new persistence unit for use either inside or outside a Java EE container. [ tell me more...]
When the Java service facade runs, the Log window displays the result of the execution of the class running outside the Java EE container, returning the quantity values that are greater than 3 in the retrieved records: [ tell me more...]
When you double-click persistence.xml in the Application Navigator, the file opens in the default editor. Click Overview to view the file in the overview editor for the JPA Persistence Descriptor. [ tell me more...]
After creating the data model, you can expose the EJB as a data control for the Oracle ADF framework. This simplifies the binding of the user interface to the EJB. [ tell me more...]
The local interface is used for clients that run in the same virtual machine, such as web clients. You will be building web pages for this application, so Local is the appropriate selection. [ tell me more...]
The root node of the Data Controls panel represents the data control registered for the business service. While the data control itself is not an item you can select, you may select among the operations it supports. [ tell me more...]
Copyright © 1997, 2009, Oracle. All rights reserved.