Professional Documents
Culture Documents
Page 1 of 12
What makes these objects different from other Java files are the annotations that identify them as EJB entities.
A key feature of EJB 3.0 and JPA is the ability to create entities that contain object-relational mappings by using metadata
annotations rather than deployment descriptors as in earlier versions.
3. In the Source editor, open the Entity node to visualize the @NamedQuery statement within the @NamedQueries annotation.
Named queries enable you to define queries at design time and then use them at run time.
Creating the FacadeBean created one NamedQuery metadata statement in the Employee entity. This query retrieves all
rows from the Employees table:
@NamedQueries({ @NamedQuery(name = "Employees.findAll", query = "select o from Employees o") })
4. Add a comma after the closing parenthesis of the NamedQuery statement and hit Enter to add a new line.
5. Add a query to the class that retrieves data about employees having a salary greater than a parameter value. Add the following
statement:
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, JPA... Page 2 of 12
If required, use the ALT + Enter keystroke combination to import the javax.persistence.NamedQueries library.
Description
@Entity
@NamedQuery
@Table
@Id
@Column
@ManyToOne
@JoinColumn
Specifies the join column and referenced column for a foreign key relationship
6. Click the Make icon to compile your project and check that no errors are returned.
7. In the Application Navigator, right-click HRFacadeBean.java and select Edit Session Facade from context.
8. In the Specify Session Facade Options, check the new query you just added getEmployeesFindBySal().
9. In the Application Navigator, right-click HRFacadeBean.java and select Create Data Control from context.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, JPA... Page 3 of 12
10. In the Choose EJB Interface, leave the default (local) selection and click OK.
11. In the Data Control Registry, expand the HRFacadeLocal node. Open the new method you just created and click the
Employees node. Notice the existing attributes corresponding to the EJB JPA definition.
12. Your new method is now ready to be used as a data control in your pages.
13. Click the Save All
2. In the New Gallery, select Web Tier > JSF/Facelets as the Category and ADF Task Flow as the item. Click OK.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, JPA... Page 4 of 12
3. In the Create Task Flow dialog, enter findBySalFlow.xml. Create as a bounded task flow with page fragments. Click OK.
5. Drag and drop a second View component onto the task flow.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, JPA... Page 5 of 12
Notice the circle around view1. It represents the entry point within the task flow.
A bounded task flow has a single point of entry, a default activity that executes before all other activities in the task flow.
6. Select the Control Flow Case component and clicking in view1, drop it onto view2. Rename the flow find.
7. Repeat the operation to create a second Control Flow Case from view2 to view1 and rename it back.
8. Double-click view1 to create the page. In the Create ADF Page Fragment the page should be a jsff file type.
Click OK.
A page fragment is a JSF document that renders as content in another JSF page.
Page fragments are typically used in bounded task flows that can be added to a JSF page as a region
9. Open the Data Controls pane, and drop the getEmployeesFindBySal() method onto the page as Parameter --> ADF
Parameter Form.
10. In the Edit Form Fields enter Salary > in the Display Label field and click OK to accept other defaults. Notice the parameter
p_sal.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, JPA... Page 6 of 12
11. Select the getEmployeesFindBySal button. Then in the Property Inspector, set the Action property to find from the list and the
12. From the Component Palette, in the Operations library, select Set Action Listener and drop it onto the Find button.
You use the Set Action Listener to hold the parameter value typed in View1 at a pageFlowScope level.
13. In the Insert Set Action Listener dialog, click the down arrow next to the From field and select Expression Builder.
14. In the Expression Builder, expand ADF Bindings > bindings and select getEmployessFindBySal_p_sal.
Click OK.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, JPA... Page 7 of 12
15. Back in the Insert Set Action Listener dialog, in the To field, enter #{pageFlowScope.sal}.
Click OK.
16. The Structure pane and the property inspector should now look like the following:
17. Click the findBySalFlow.xml tab to reopen the task flow diagram. In the task flow diagram, double click view2 to create the
page.
18. In the Create ADF Page fragment, accept the default values.
Click OK.
19. In the Data Controls pane, expand the getEmployeesFindBySal() method then drag and drop Employees onto the page. Select
20. In the Edit Table Columns dialog, select Single Row , Enable Sorting and Enable Filtering. Delete all columns after salary
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, JPA... Page 8 of 12
Click OK.
21. In the Edit Action Binding dialog, in the Value field enter #{pageFlowScope.sal}.
Click OK.
23. In the Property Inspector, enter Back as Text and select back for the action.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, JPA... Page 9 of 12
4. In the Application Navigator, expand the Web Content > WEB-INF nodes and drag and drop the findBySalFlow.xml node
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, J... Page 10 of 12
A primary reason for executing a bounded task flow as an ADF region is reuse.
You can isolate specific pieces of application functionality in a bounded task flow and an ADF region in order to reuse it
throughout the application.
You can extract, configure, and package application functionality within a bounded task flow so that it can be added to other
pages using an ADF region. ADF regions can be reused wherever needed, which means they are not dependent on a
parent page.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, J... Page 11 of 12
3. Enter a value in the Salary field (for example 8000) and click the Find button.
4. A list of the corresponding employees is returned. Scroll right to verify that no salaries =< 8000 are returned.
6. Enter a new value in the Salary field (for example 10000) and click the Find button.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012
Oracle JDeveloper 11g Release 2 Tutorials - Building a Web Application Using EJB, J... Page 12 of 12
Previous 1 2 3 4 Next
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_51/jdtut_11r2_51_3.html
08/03/2012