增加:
第一种方法:【利用参数】
public static String GetDepartmentIDByInsert(String DepartName, int ParentID)
{
String sqlInsert="insert into department (DepartName,ParentID) values('"+DepartName+"',"+ParentID+" )";
DMLStatement dml = new DMLStatement(sqlInsert);
String sqlQuery="select LAST_INSERT_ID() as id from dual ";
QueryObject query = new QueryObject(sqlQuery);
query.setResultClass(AnonymousBusObject.class);
dml.executeDML();
AnonymousBusObject boit = (AnonymousBusObject)query.getObject();
String resultValue = boit.getStringProperty("id");
return resultValue;
}
</span>
第二种方法:【利用利用对象,在定义接口时候,可以把整个对象作为一个参数】
WebService接口
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<SaveOrganization xmlns="http://com.unicom.bopm/organization" preserveSpace="no" qAccess="0" qValues="">
<organization>
<SM_ORGANIZATION>
<ORG_ID>PARAMETER</ORG_ID>
<ORG_NAME>PARAMETER</ORG_NAME>
<PARENT_ID>PARAMETER</PARENT_ID>
<ORG_CODE>PARAMETER</ORG_CODE>
<TENANT_DN>PARAMETER</TENANT_DN>
<ORG_LEVEL>PARAMETER</ORG_LEVEL>
<IS_COMPANY>PARAMETER</IS_COMPANY>
<IS_COUNTY>PARAMETER</IS_COUNTY>
<IS_VIRTUAL_ORG>PARAMETER</IS_VIRTUAL_ORG>
<IS_TENANT_ROOT>PARAMETER</IS_TENANT_ROOT>
<SORT_NO>PARAMETER</SORT_NO>
<STATUS_SIGN>PARAMETER</STATUS_SIGN>
<CREATE_PERSON>PARAMETER</CREATE_PERSON>
<CREATE_TIME>PARAMETER</CREATE_TIME>
<DESC_MEMO>PARAMETER</DESC_MEMO>
</SM_ORGANIZATION>
</organization>
</SaveOrganization>
</SOAP:Body>
</SOAP:Envelope>
后台接口
public static String saveOrganization(com.unicom.bopm.organization.SM_ORGANIZATION organization)
{
return OrganizationManager.saveOrganization(organization);
}
删除
第一种方法:
public static void DeleteByID(int ID)
{
String stringText = "delete from department where ID =:ID";
DMLStatement dml = new DMLStatement(stringText);
dml.addParameter("ID", "department.ID", ID);
dml.executeDML();
}
第二种方法:
SM_MENU currentMenuObj=null;
String currentMenuQT="SELECT * FROM SM_MENU M WHERE M.MENU_ID=:MENU_ID";
QueryObject currentMenuQ = new QueryObject(currentMenuQT);
currentMenuQ.addParameter("MENU_ID","SM_MENU.MENU_ID", QueryObject.PARAM_STRING, menu_id);
currentMenuQ.setResultClass(SM_MENU.class);
currentMenuObj=(SM_MENU) currentMenuQ.getObject();
currentMenuObj.setSTATUS_SIGN(status_sign);
currentMenuObj.delete();
修改
第一种方法
public static void UpdateByName(String Name,int ID)
{
String sqlUpdate="update department set DepartName='"+Name+"' where ID="+ID;
DMLStatement dml = new DMLStatement(sqlUpdate);
dml.executeDML();
}
第二种方法:
BusObjectIterator<SM_MENU> childMenusObj = null;
String childMenusQT="SELECT * FROM SM_MENU M WHERE M.PARENT_ID=:MENU_ID";
QueryObject childMenusQ = new QueryObject(childMenusQT);
childMenusQ.addParameter("MENU_ID","SM_MENU.MENU_ID", QueryObject.PARAM_STRING, menu_id);
childMenusQ.setResultClass(SM_MENU.class);
childMenusObj=childMenusQ.getObjects();
while(childMenusObj.hasMoreElements())
{
SM_MENU obj=(SM_MENU)childMenusObj.nextElement();
obj.setSTATUS_SIGN(status_sign);
obj.update();
}
查询
public static BusObjectIterator<com.commonpackage.department> GetDepartmentByParentID(int ParentID)
{
String queryText = "select * from department where ParentID= :ID";
QueryObject query = new QueryObject(queryText);
query.addParameter("ID", "department.ParentID", QueryObject.PARAM_INT ,ParentID);
query.setResultClass(department.class);
return query.getObjects();
}