日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

OAF 中的EO 和VO

發布時間:2023/12/13 综合教程 32 生活家
生活随笔 收集整理的這篇文章主要介紹了 OAF 中的EO 和VO 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。