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. 廖雪峰JavaScript学习摘录

    一. 1.语法基础: (1)特别注意相等运算符==.JavaScript在设计时,有两种比较运算符: 第一种是==比较,它会自动转换数据类型再比较,很多时候,会得到非常诡异的结果: 第二种是===比较 ...

  2. "\r\n","\r","\n"

    参考: http://blog.csdn.net/xiaofei2010/article/details/8458605 '\r' : 回车符 '\n' : 换行符 以下是c++语言的测试代码, 跟平 ...

  3. Unity5中的MetaPass

    前些天烘焙lightmap的时候发现用自己写的Shader的模型在烘焙时候不会烘焙效果不对,它不会产生对周围物体的间接光照,但是我放到了unity4.x中就是没问题的.查了一番,发现Unity5中加了 ...

  4. Android Studio in OSX 提高工作效率的快捷键

    前言 本篇文章参考了<倍数提高工作效率的Android Studio>一文,快捷键基于OS X系统. OS X Yosemite 10.10.5 Android Studio 1.3.1 ...

  5. (转)关于URLDownloadToFile下载文件

    转自:http://zhouhaijiang3.blog.163.com/blog/static/43477220200931981322497/ 在下载文件时,下载文件的目录大小写要注意和虚拟目录的 ...

  6. Jmeter组件6. SOAP/XML-RPC Request

    Jmeter测试SOAP的web services现在有两种方式 第一是使用SOAP/XML-RPC Request组件,第二使用HTTP Request组件 Send SOAPACtion, 同ht ...

  7. Junit4断言

    Junit4断言API: http://junit.org/javadoc/latest/index.html Constructor Summary protected Assert()       ...

  8. SSH Tunneling

    把本地端口 local_port 转发到服务器 server2 的 remote_port 端口上, server1 和 server2可以是同一ip或者不同ip. ssh user@server1 ...

  9. 会话状态已创建一个会话 ID,但由于响应已被应用程序刷新而无法保存它

    解决方法是新建 全局应用程序类 Global.asax 在 Session_Start 函数中 添加 string sessionId = Session.SessionID; protected v ...

  10. High Memory in the Linux Kernel

    This is enabled via the PAE (Physical Address Extension) extension of the PentiumPro processors. PAE ...