ADF-BC EO 介绍.ppt

上传人:罗晋 文档编号:9289763 上传时间:2021-02-15 格式:PPT 页数:21 大小:448.50KB
返回 下载 相关 举报
ADF-BC EO 介绍.ppt_第1页
第1页 / 共21页
ADF-BC EO 介绍.ppt_第2页
第2页 / 共21页
ADF-BC EO 介绍.ppt_第3页
第3页 / 共21页
ADF-BC EO 介绍.ppt_第4页
第4页 / 共21页
ADF-BC EO 介绍.ppt_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《ADF-BC EO 介绍.ppt》由会员分享,可在线阅读,更多相关《ADF-BC EO 介绍.ppt(21页珍藏版)》请在三一文库上搜索。

1、ADF-BC EO 介绍,资深技术顾问 甲骨文 开发者计划,ADF-BC Entities Object,Characteristics of Entity Objects,Entity objects: Represent a row in a database table or other data source Handle database caching Contain attributes representing the database columns Encapsulate attribute-level and entity-level validation logic C

2、an contain custom business methods,Using Entity Objects to Persist Data,CustomersEO,IdNameStatusEmail,Entity object,Attributes,Database table,Status List(Gold Silver Platinum),Validation rule,ID,201,NAME,Steve,STATUS,Gold,Email,202,Mike,Silver,CUSTOMERS,Creating Entity Objects from Tables, Views, or

3、 Synonyms,When you create an entity object, JDeveloper: Interrogates the data dictionary for information about attribute Names, types, relationships based on primary/foreign key relationships, Infers primary key, or creates one from RowID Creates implicit validators for database constraints Creates

4、the XML component definition file (.xml) Creates optional Java files if selected, such as entity object class Impl.java Generates associations based on foreign keys, if applicable (FkAS.xml) these should be renamed,Modifying the Default Behavior of Entity Objects,With declarative settings, you can:

5、Define attribute control hints Use alternate key entity constraints Refactor (rename or move) objects Create and publish events Validate user input (presented in a later lesson) Many other modifications are possible with coding, such as: Overriding base class methods Implementing calculation and rec

6、alculation of transient attributes,Defining Attribute Control Hints,1,2,Associations,Define a relationship between EOs Facilitate access to data in related entity objects May be based on database constraints May be independent of database constraints Are used in defining validations and LOV metadata

7、 Consist of a source (master) and a destination (detail) entity,Source,Destination,OrdersPersonsFkAS,Association,PersonsEO,OrdersEO,Creating Associations,Automatically created when creating 2nd EO with foreign key,Creating Associations,Using the Create Association wizard,Association Types,Associatio

8、n Entities are related but not completely dependent Either end of the association can exist without the other Either can be deleted without deleting the other Composition Destination entity is completely dependent on the source entity The source entity owns the destination entity No destination enti

9、ty can be created without the owning entity existing first The source entity cannot be deleted without deleting all its associated destination entities,Using Alternate Key Entity Constraints,Alternate keys are: Used for efficient uniqueness checks Used for direct row lookups with findByKey() methods

10、 Different from primary keys or unique keys,Refactoring Objects,With refactoring you can: Rename objects, such as associations and view links Move objects or packages to a different package Change all references throughout the application,Working Programatically with Entities and Associations,Findin

11、g an Entity Object by Primary Key,publicStringfindOrderID(longorderId) StringentityName=oracle.apps.str.model.entity.OrderEO; EntityDefImplorderDef=EntityDefImpl.findDefObject(entityName); KeyorderKey=newKey(newObjectorderId); EntityImplorder=orderDef.findByPrimaryKey(getDBTransaction(), orderKey);

12、if(order!=null) return(String)order.getAttribute(“ShipToName); else returnnull; ,1,2,3,4,public String getLocationId() return getDepartmentEO().getLocationId(); ,Traversing Associations:Source to Destination,The destination entitys EntityImpl.java file contains methods to get and set the source enti

13、ty. For example, EmployeeEOImpl.java contains getDepartmentEO() and setDepartmentEO(). You could add a method to EmployeeEO.java to get the Location ID of the department to which the employee belongs:,getEmployeeEO(),DepartmentEO,DepartmentEOToEmployeeEO,EmployeeEO,getDepartmentEO()getLocationId(),U

14、pdating or Removingan Existing Entity Row,publicvoidupdateEmpEmail(longempId,StringnewEmail) EntityImplemp=retrieveEmployeeById(empId); if(emp!=null) emp.setAttribute(“Email,newEmail); try getDBTransaction().commit(); catch(JboExceptionex) getDBTransaction().rollback(); throwex; ,1,2,3,Creating a Ne

15、w Entity Row,publiclongcreateProduct(Stringname,Stringdescription) StringentityName=“oracle.apps.str.model.entity.ProductEO; EntityDefImplproductDef=EntityDefImpl.findDefObject(entityName); EntityImplnewProduct= productDef.createInstance2(getDBTransaction(),null); newProduct.setAttribute(Name,name);

16、 newProduct.setAttribute(Description,description); try getDBTransaction().commit(); catch(JboExceptionex) throwex; DBSequencenewIdAssigned= (DBSequence)newProduct.getAttribute(ProdId); returnnewIdAssigned.getSequenceNumber().longValue();,1,2,3,4,5,Coding: The Supporting Java Classes,EntityImpl The e

17、ntity class Represents a row Provides getter and setter methods EntityDefImpl The entity definition class Represents the whole entity Can be used to modify the entity definition EntityCollImpl Represents the cached set of rows from the entity It is not necessary to modify or override methods in this

18、 class,Overriding Base Class Methods,You can override methods in the base classes for objects. For example, you can override methods in EntityImpl.java, such as: doDML() Use to log changes in another entity beforeCommit() Use to validate multiple instances of the same entity remove() Use to log a de

19、letion in an entity,Overriding Base Class Methods Example: Updating a Deleted Flag Instead of Deleting Rows,/ In Impl.java public void remove() setDeleted(Y); super.remove(); protected void doDML(int operation, TransactionEvent e) if (operation = DML_DELETE) operation = DML_UPDATE; super.doDML(operation, e); ,1,2,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1