版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、ADF-BC EO 介绍介绍资深技术顾问甲骨文 开发者计划ADF-BC Entities ObjectCharacteristics of Entity ObjectsEntity 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 Can
2、contain custom business methodsUsing Entity Objects to Persist DataCustomersEOIdNameStatusEmailEntity objectAttributesDatabase tableStatus List(Gold Silver Platinum)Validation ruleID201NAMESteveSTATUSGoldEmail202MikeSilverCUSTOMERSCreating Entity Objects from Tables, Views, or SynonymsWhen you creat
3、e 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 the XML component defini
4、tion 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 renamedModifying the Default Behavior of Entity Objects With declarative settings, you can: Define attribute control
5、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 recalculation of transient a
6、ttributesDefining Attribute Control Hints12Associations 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 Consist of a source (master)
7、 and a destination (detail) entitySourceDestinationOrdersPersonsFkASAssociationPersonsEOOrdersEOCreating Associations Automatically created when creating 2nd EO with foreign keyCreating Associations Using the Create Association wizardAssociation Types Association Entities are related but not complet
8、ely 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 entity can be created without the owning e
9、ntity existing first The source entity cannot be deleted without deleting all its associated destination entitiesUsing Alternate Key Entity ConstraintsAlternate keys are: Used for efficient uniqueness checks Used for direct row lookups with findByKey() methods Different from primary keys or unique k
10、eysRefactoring ObjectsWith refactoring you can: Rename objects, such as associations and view links Move objects or packages to a different package Change all references throughout the applicationWorking Programatically with Entities and AssociationsFinding an Entity Object by Primary KeypublicStrin
11、gfindOrderID(longorderId)StringentityName=oracle.apps.str.model.entity.OrderEO;EntityDefImplorderDef=EntityDefImpl.findDefObject(entityName);KeyorderKey=newKey(newObjectorderId);EntityImplorder=orderDef.findByPrimaryKey(getDBTransaction(),orderKey);if(order!=null)return(String)order.getAttribute(“Sh
12、ipToName);elsereturnnull;1234public String getLocationId() return getDepartmentEO().getLocationId(); Traversing Associations:Source to Destination The destination entitys EntityImpl.java methods to get and set the source entity. For example, EmployeeEOImpl.java contains getDepartmentEO() and setDepa
13、rtmentEO(). You could add a method to EmployeeEO.java to get the Location ID of the department to which the employee belongs:getEmployeeEO()DepartmentEODepartmentEOToEmployeeEOEmployeeEOgetDepartmentEO()getLocationId()Updating or Removingan Existing Entity Rowpublic void updateEmpEmail(long empId, S
14、tring newEmail) EntityImpl emp = retrieveEmployeeById(empId); if (emp != null) emp.setAttribute(“Email,newEmail); try getDBTransaction().commit(); catch (JboException ex) getDBTransaction().rollback(); throw ex; 123Creating a New Entity Rowpublic long createProduct(String name, String description) S
15、tring entityName = “oracle.apps.str.model.entity.ProductEO; EntityDefImpl productDef = EntityDefImpl.findDefObject(entityName); EntityImpl newProduct = productDef.createInstance2(getDBTransaction(),null); newProduct.setAttribute(Name,name); newProduct.setAttribute(Description,description); try getDB
16、Transaction().commit(); catch (JboException ex) throw ex; DBSequence newIdAssigned = (DBSequence)newProduct.getAttribute(ProdId); return newIdAssigned.getSequenceNumber().longValue(); 12345Coding: The Supporting Java Classes EntityImpl The entity class Represents a row Provides getter and setter met
17、hods 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 classOverriding Base Class MethodsYou 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 deletion in an entityOverri
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 公司与公司劳务协议书
- 出租摊位定金合同范本
- 公司装修安全合同范本
- 厂家与代理商合同协议
- 借款无需偿还的协议书
- 农村大棚出租合同范本
- 劳务资质借用合同范本
- 生物科技行业投资机会
- 农村村民修房合同范本
- 位临时工转包合同范本
- 湖南省部分校2025-2026学年高二上学期10月联考语文试题(含答案)(解析版)
- 2025贵州惠水县选聘城市社区工作者3人考试模拟试题及答案解析
- 大学高等数学上习题附答案
- 生产车间现场管理规定
- 2025年广东省中考英语试卷深度评析及2026年备考策略
- 2025至2030年中国智慧实验室建设行业市场运营态势及投资前景研判报告
- 定额〔2025〕1号文-关于发布2018版电力建设工程概预算定额2024年度价格水平调整的通知
- 广告及宣传用品设计申请单
- 教师职称考试试题
- GB/T 13275-1991一般用途离心通风机技术条件
- 高效课堂教学模式培训(数学)课件
评论
0/150
提交评论