SM_TENANT_MENU tenant_menu=new SM_TENANT_MENU(BusObjectConfig.TRANSIENT); 临时变量
当 如果是从数据库 query.getObjects();取出时,可以用 tenant_menu.makeTransient();
很多时候,我们通过cordys给我们提供的查询方法 返回对象后, query.getObjects(); 我们可能 想改变 某个特定对象的值,则我们可以直接用for循环 找到这个对象,改变值即可
例如:
BusObjectIterator<langinfo>langinfos=query.getObjects();
while(langinfos.hasMoreElements()){
langinfoinfo=langinfos.nextElement();
info.makeTransient();
info.lang="11";
}
改完后 直接 返回langinfos即可,无需 在整个容器,往容器里一个个添加,添加完后再返回,这是Cordys与普通java的不同 。
很多时候,我们可能是这样,要拼接 通过我们常用的 容器 来拼接对象 如: Vector ArrayList 等 ,我们需要
VectorfinalResult = new Vector();
new BusObjectArray(finalResult);
转换为: BusObjectIterator
public static BusObjectIteratorgetCustomersObjects(String fromCustomerID, String toCustomerID)
{
// 1. get the original result
BusObjectIterator originalResult =CustomersBase.getCustomersObjects(fromCustomerID, toCustomerID);
// 2. create Vector to store the finalresult
Vector finalResult = new Vector();
// 3. fill the finalResult based on theoriginalResult
// for example: filter out someelements
while (originalResult.hasMoreElements() )
{
Customers c =(Customers)originalResult.nextElement();
// add to the final result?
if ( some_condition )
{
finalResult.add(c);
}
}
// if required: do more processing onfinal result
// 4. make a BusObjectIterator out ofthe Vector and return it
return new BusObjectArray(finalResult);
}
SM_TENANT_MENUtenant_menu=new SM_TENANT_MENU(); 虽然没有 写 tenant_menu.insert(); 但,事物提交完后,默认会执行Insert方法
public void_changeObject() {
this.m_objectState.onChange();
}
protected void onAfterLoad() {
log("OnAfterLoad");
}
protected void onBeforeInsert() {
log("OnBeforeInsert");
}
protected void onAfterInsert() {
log("OnAfterInsert");
}
protected void onBeforeUpdate() {
log("OnBeforeUpdate");
}
protected void onAfterUpdate() {
log("OnAfterUpdate");
}
protected void onBeforeDelete() {
log("OnBeforeDelete");
}
protected void onAfterDelete() {
log("OnAfterDelete");
}
充分利用主外键 的关系来
States of a BusObject |
|
The following flow diagram portrays thedifferent states of a BusObject.
The various states are explained in the following table.
Table 1. States of a BusObject
State | Description |
N (new) | Indicates that an object has just been created. |
NI (inserted) | Indicates that an insert () operation has been performed on the object. When the object is changed, it attains the NC (new + changed) state. When the object is committed, it attains the L (loaded) state. |
NC (new + changed) | Indicates that an object, which has just been created, has been changed. |
t (transient) | Indicates that the object is independent of any transaction. In such a state, committing a transaction will not affect the object. If an insert () operation is performed on an object in this state, the object attains the NI (inserted) state. |
L (loaded) | Indicates that the object has just been loaded from the database into a transaction (for example, using a query). It also indicates that currently the object content has not undergone any change. An object attains this state as soon as it is inserted or updated in the database. |
LC (loaded + changed) | Indicates that the contents of the object are changed. |
LU (updated) | Indicates that an update () operation has been performed on the object. As soon as one of the attributes of the object is updated, it attains the LC state. |
LD (deleted) | Indicates that a delete () operation has been performed on the object. |