(#---------------程式--------------------------=) package BC4JDemo; import oracle.jbo.server.EntityImpl; import oracle.jbo.server.EntityDefImpl; import oracle.jbo.server.AttributeDefImpl; import oracle.jbo.domain.Number; import oracle.jbo.Key; import oracle.jbo.RowIterator; // --------------------------------------------------------------- // --- File generated by Oracle Business Components for Java. // --------------------------------------------------------------- public class DeptImpl extends EntityImpl { protected static final int DEPTNO = 0; protected static final int DNAME = 1; protected static final int LOC = 2; protected static final int EMP = 3; private static EntityDefImpl mDefinitionObject; /** * * This is the default constructor (do not remove) */ public DeptImpl() { } /** * * Retrieves the definition object for this instance class. */ public static synchronized EntityDefImpl getDefinitionObject() { if (mDefinitionObject == null) { mDefinitionObject =     (EntityDefImpl) EntityDefImpl.findDefObject("BC4JDemo.Dept"); } return mDefinitionObject; } /** * * Gets the attribute value for Deptno, using the alias name Deptno */ public Number getDeptno() { return (Number)getAttributeInternal(DEPTNO); } /** * * Sets value as the attribute value for Deptno */ public void setDeptno(Number value) { setAttributeInternal(DEPTNO, value); } /** * * Gets the attribute value for Dname, using the alias name Dname */ public String getDname() { return (String)getAttributeInternal(DNAME); } /** * * Sets value as the attribute value for Dname */ public void setDname(String value) { setAttributeInternal(DNAME, value); } /** * * Gets the attribute value for Loc, using the alias name Loc */ public String getLoc() { return (String)getAttributeInternal(LOC); } /** * * Sets value as the attribute value for Loc */ public void setLoc(String value) { setAttributeInternal(LOC, value); } // Generated method. Do not modify. protected Object getAttrInvokeAccessor(int index,    AttributeDefImpl attrDef) throws Exception { switch (index) { case DEPTNO: return getDeptno(); case DNAME: return getDname(); case LOC: return getLoc(); case EMP: return getEmp(); default: return super.getAttrInvokeAccessor(index, attrDef); } } // Generated method. Do not modify. protected void setAttrInvokeAccessor(int index,   Object value, AttributeDefImpl attrDef) throws Exception { switch (index) { case DEPTNO: setDeptno((Number)value); return; case DNAME: setDname((String)value); return; case LOC: setLoc((String)value); return; default: super.setAttrInvokeAccessor(index, value, attrDef); return; } } /** * * Gets the associated entity oracle.jbo.RowIterator */ public RowIterator getEmp() { return (RowIterator)getAttributeInternal(EMP); } /** * * Creates a Key object based on given key constituents */ public static Key createPrimaryKey(Number deptno) { return new Key(new Object[] {deptno}); } } 下列範例為Dept.xml的檔案內容: (#---------------程式--------------------------=) (#---------------程式--------------------------=) package BC4JDemo; import oracle.jbo.server.ViewObjectImpl; // --------------------------------------------------------------- // --- File generated by Oracle Business Components for Java. // --------------------------------------------------------------- public class DeptViewImpl extends ViewObjectImpl { /** * * This is the default constructor (do not remove) */ public DeptViewImpl() { } } 下列範例是DeptView.xml的檔案內容; (#---------------程式--------------------------=) (#---------------程式--------------------------=) SELECT Dept.DEPTNO, Dept.DNAME, Dept.LOC FROM DEPT Dept WHERE Dept.DEPTNO = 30 (#---------------程式-------------------------=) (#-----------程式---------------=) 下列範例是BC4JdemoModuleImpl.java的檔案內容: (#-----------程式---------------=) package BC4JDemo; import oracle.jbo.server.ApplicationModuleImpl; import oracle.jbo.server.ViewLinkImpl; // --------------------------------------------------------------- // --- File generated by Oracle Business Components for Java. // --------------------------------------------------------------- public class BC4JDemoModuleImpl extends ApplicationModuleImpl { /** * * This is the default constructor (do not remove) */ public BC4JDemoModuleImpl() { } /** * * Container's getter for EmpView1 */ public EmpViewImpl getEmpView1() { return (EmpViewImpl)findViewObject("EmpView1"); } /** * * Container's getter for DeptView1 */ public DeptViewImpl getDeptView1() { return (DeptViewImpl)findViewObject("DeptView1"); } /** * * Container's getter for EmpView2 */ public EmpViewImpl getEmpView2() { return (EmpViewImpl)findViewObject("EmpView2"); } /** * * Container's getter for FkDeptnoLink1 */ public ViewLinkImpl getFkDeptnoLink1() { return (ViewLinkImpl)findViewLink("FkDeptnoLink1"); } /** * * Sample main for debugging Business Components code using the tester. */ public static void main(String[] args) { launchTester("BC4JDemo", "BC4JDemoModuleLocal"); } }