EO :oracle.apps.fnd.framework.server.OAEntityImpl

VO:oracle.apps.fnd.framework.server.OAViewRowImpl

1.准备插入的视图VO

此VO 只是插入行,不从数据库中查询。则此时必须 setMaxFetchSize(0)进行初始化。

AM 中的逻辑代码:

//检查并确保 VO 中没有行,在插入之前进行初始化

if (vo.getFetchedRowCount() == 0)

{

vo.setMaxFetchSize(0);

}

// Perform insert

 Row row = vo.createRow();

vo.insertRow(row);

//如果row是事物的,则进行此设置

row.setNewRowState(Row.STATUS_INITIALIZED);

2.EO 中的create  

(1).简单的单表create

// AM

public void create()

{

OAViewObject vo = getSuppliersVO();

vo.insertRow(vo.createRow());

//插入行之后重新设置row状态

vo.setNewRowState(Row.STATUS_INITIALIZED);

}

/** 在EOImpl中可以初始化插入的行 */
Public void create(AttributeList attributeList)
{
  super.create(attributeList); 
  OADBTransaction transaction = getOADBTransaction();
  // ID 从表序列中获得
  Number supplierId = transaction.getSequenceValue("FWK_TBX_SUPPLIERS_S");
  setSupplierId(supplierId);

  // Start date设置为当前时间
  setStartDate(transaction.getCurrentDBDate());
}  

给table插入新的行后,立即设置 setNewRowState(STATUS_INITIALIZED)

这样的话BC4J 就会删除EO相对应的事物和验证监听,因此设置后将不会验证或提交给数据库

(2)主从关系表的create

3.EO 中验证主键是否唯一 在SupplierEOImpl

public void setSupplierId(Number value)
{ 
  if (value != null)
  {
     //Supplier id 必须唯一,findByPrimaryKey()确保检查所有的suppliers,首先它检查entity缓存,然后检查数据库
   OADBTransaction transaction = getOADBTransaction();
    Object[] supplierKey = {value};
    EntityDefImpl supplierDefinition = SupplierEOImpl.getDefinitionObject();
    SupplierEOImpl supplier = 
      (SupplierEOImpl)supplierDefinition.findByPrimaryKey(transaction, new Key(supplierKey));
    if (supplier != null)
    {
      throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
             getEntityDef().getFullName(), // EO name
             getPrimaryKey(), // EO PK
             "SupplierId", // Attribute Name
             value, // Bad attribute value
             "ICX", // Message application short name
             "FWK_TBX_T_SUP_ID_UNIQUE"); // Message name 
    }
  }
  
  setAttributeInternal(SUPPLIERID, value);
}  

4. EO 的删除

/*删除采购订单从PoSimpleSummaryVO根据poHeaderId 参数*/

public Boolean delete(String poHeaderId)

{

int poToDelete = Integer.parseInt(poHeaderId);

OAViewObject vo = getPoSimpleSummaryVO();

PoSimpleSummaryVORowImpl row = null;

//缓存中的行数

int fetchedRowCount = vo.getFetchedRowCount();

boolean rowFound = false;

// 用iterator

RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");

if (fetchedRowCount > 0)

{

deleteIter.setRangeStart(0);

deleteIter.setRangeSize(fetchedRowCount);

for (int i = 0; i < fetchedRowCount; i++)

{

row = (PoSimpleSummaryVORowImpl)deleteIter.getRowAtRangeIndex(i);

// Number primaryKey = (Number)row.getAttribute("HeaderId");

Number primaryKey = row.getHeaderId();

if (primaryKey.compareTo(poToDelete) == 0)

{

row.remove();

rowFound = true;

getTransaction().commit();

break; // only one possible selected row in this case

}

}

}

// Always close iterators.

deleteIter.closeRowSetIterator();

return new Boolean(rowFound);

}

5.EO 验证name 不为空,且唯一

SupplierEOImpl

public void setName(String value)
{
if ((value != null) || (!("".equals(value.trim()))))
{
// 验证name是否唯一,将先从entity 缓存,然后在数据库检查.
com.sun.java.util.collections.Iterator supplierIterator =
getEntityDef().getAllEntityInstancesIterator(getDBTransaction());
Number currentId = getSupplierId(); while ( supplierIterator.hasNext() )
{
SupplierEOImpl cachedSupplier = (SupplierEOImpl)supplierIterator.next();
String cachedName = cachedSupplier.getName();
Number cachedId = cachedSupplier.getSupplierId(); // 如果数据库可以查询出来相同的name和ID则抛异常. If (cachedName != null && value.equalsIgnoreCase(cachedName) &&
cachedId.compareTo(currentId) != 0 )
{
throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(), // EO name
getPrimaryKey(), // EO PK
"Name", // Attribute Name
value, // Attribute value
"ICX", // Message product short name
"FWK_TBX_T_SUP_DUP_NAME"); // Message name
}
} // 检查数据库

OADBTransaction transaction = getOADBTransaction();
OAApplicationModule vam;
//查看am是否创建,如果没有创建,则在事物中创建.
vam = (OAApplicationModule)transaction.findApplicationModule("supplierVAM");
if (vam == null)
{
vam =
(OAApplicationModule)transaction.createApplicationModule("supplierVAM",
"oracle.apps.fnd.framework.toolbox.schema.server.SupplierVAM");
}
SupplierNameVVOImpl valNameVo = (SupplierNameVVOImpl)vam.findViewObject("SupplierNameVVO");
valNameVo.initQuery(value);
if (valNameVo.hasNext())
{
throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(), // EO name
getPrimaryKey(), // EO PK
"Name", // Attribute Name
value, // Attribute value
"ICX", // Message application short name
"FWK_TBX_T_SUP_DUP_NAME"); // Message name
}
}
setAttributeInternal(NAME, value);
}
事务锁
// In the application module...
OADBTransaction txn = getOADBTransaction();
txn.setLockingMode(Transaction.LOCK_PESSIMISTIC);
事物提交:
getTransaction()Commit();
事物回滚:

getTransaction().rollback();

Entity State

  • STATUS_NEW - the entity object is new in the current transaction.
  • STATUS_DELETED - the entity object originated in the database and has been deleted in the current transaction.
  • STATUS_MODIFIED - the entity object originated in the database and has been changed.
  • STATUS_UNMODIFIED - the entity object originated in the database and has not been changed, or it has been changed and those changes have been committed.
  • STATUS_DEAD - the entity object is new in the current transaction and it has been deleted.
  • STATUS_INITIALIZED - the entity object is in a "temporary" state and will not be posted or validated.

OAF 中的EO 和VO的更多相关文章

  1. OAF中为MessageTextInput添加加事件处理

    需求:现在OAF页面上有俩输入框,单价,数量,根据单价数量,自动计算MessageStyledText金额中的值,对应的基于EO的VO的字段为UnitPrice,Quantity,Total. 实现方 ...

  2. OAF_开发系列29_实现OAF中批次处理迭代器RowSet/RowSetIterator(案例)

    20150814 Created By BaoXinjian

  3. EBS OAF中如何在多行表中实现附件功能

    EBS OAF中如何在多行表中实现附件功能 (版权声明,本人原创或者翻译的文章如需转载,如转载用于个人学习,请注明出处:否则请与本人联系,违者必究) 在OAF中使用附件功能之前,要先明白Entity( ...

  4. OAF中trunc函数的使用(转)

    原文地址:OAF中trunc函数的使用 需求:在做OAF开发时,经常会需要查询功能,由于需求的不同,往往不能使用OAF标准的查询功能,需要自己客户化实现查询功能,而在查询功能中,经常会遇到查询的时间范 ...

  5. OAF中的面包屑(breadcrumbs)始无法显示(转)

    原文地址:OAF中的面包屑(breadcrumbs)始无法显示 OAF中面包屑是一种重要的导航工具.可以提示用户抵达当前页面的路径,也可以方便的切换到之前的节点. 开始做面包屑开发的时候发现面包屑总是 ...

  6. OAF中多语言的实现(转)

    正好前两天研究过这个问题,分享一下啊. 标题:        OAF中多语言的实现概述:        OAF的多语言的实现有两种方式,其一是直接通过页面上面的“个性化”连接,连接到指定的页面后,进行 ...

  7. OAF中 遍历HGrid组件中的所有VO行

    在HGrid组件中有如下所示的HeaderVO和LineVO 需要在头上的LOV中触发事件去更新行VO中的值,LOV事件的处理方法见 getLovParameter ,但是由于HGrid的特殊性,不能 ...

  8. 校验基于EO的VO中的字段是否发生变化

    I have a table region and there are multiple records fetching from a Entity based VO. Now I have upd ...

  9. java EE中使用PO和VO的注意事项

    1.基本定义  PO(Persistence Object 持久化对象)是直接跟持久层数据库打交道的java Bean (model,entity,bean等叫法都是可以的),里面除了私有的成员变量之 ...

随机推荐

  1. deep learning 练习1 线性回归练习

    线性回归练习 跟着Andrew Ng做做练习:http://openclassroom.stanford.edu/MainFolder/DocumentPage.php?course=DeepLear ...

  2. Python基础篇【第5篇】: Python模块基础(一)

    模块 简介 在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件包含的代码就 ...

  3. 01-C#入门(函数一)

    只有在动手写代码的时候,才能真正理解到代码的逻辑思想,所以,开始写代码吧. 函数的意义:降低相同功能的代码重复编写,提高重复代码的维护效率. 函数 一个文件由命令空间(namespace).类(cla ...

  4. 今天早上刚刚碰到的一个问题oracle数据归档已满,只能进行内部连接,ORA-00257 archiver error. 错误的处理方法

    archive log 日志已满ORA-00257: archiver error. Connect internal only, until freed 错误的处理方法1. 用sys用户登录  sq ...

  5. 查询oracle数据库,返回的数据是乱码。 PL/SQL正常。

    查询oracle数据库,返回的数据是乱码. PL/SQL正常. 解决方案如下:

  6. ebs如何将客户化的PL/SQL程序发布到webservice

    as:cux_gl_hec_iface_soa_pkg. 1.将package声明部分的内容拷贝出来另存为cux_gl_hec_iface_soa_pkg.pls的文件: 2.将该文件上传到服务器上拥 ...

  7. 用 javascript 脚本,网站判读来访者是手机还是电脑

    <script> var system ={}; var p = navigator.platform; system.win = p.indexOf("Win") = ...

  8. python IDLE编程时遇到Python Error: Inconsistent indentation detected! 解决方法

    仔细检查了几遍代码,发现indent没有错误! 之后试将所有indent都用空格代替,程序就跑起来了. 具体原因可能是IDLE环境内的Tab键有小bug.

  9. git 使用入门

    参考教程: 廖雪峰的官方网站 MY UBUNTU 安装: sudo apt-get install git GIT 理解: 选定的目录为git的工作区.该目录下的任何改动,git都会记录为工作区的修改 ...

  10. 谈谈Java面向对象的三大特性

    Java面向对象的三大特性就是指封装.继承.多态了. 一.封装: 概念:封装是指隐藏对象的属性和实现细节,仅对外提供公共访问方式. (举例:笔记本电脑就是一个封装体,Java语言中最小的封装体就是函数 ...