1、查询单张表,有过滤条件和排序
1 //要按日期排序 2 EntityViewInfo viewInfo =new EntityViewInfo(); 3 FilterInfo filterInfo = new FilterInfo(); 4 filterInfo.getFilterItems().add(new FilterItemInfo("bankNumber",bankNo.trim())); 5 filterInfo.getFilterItems().add(new FilterItemInfo("amount",money.trim())); 6 filterInfo.getFilterItems().add(new FilterItemInfo("isexecuted",false)); 7 filterInfo.getFilterItems().add(new FilterItemInfo("CollectionFlag","X"));//已出盘 8 filterInfo.getFilterItems().add(new FilterItemInfo("CollectionFlag","Y"));//已回盘 9 //查询 已出盘+标志为'0' 或者 已回盘+'1' 10 filterInfo.setMaskString("#0 and #1 and #2 and (#3 or #4)"); 11 viewInfo.setSorter(new SorterItemCollection()); 12 viewInfo.getSorter().add(new SorterItemInfo("StartDate"));//排序 13 viewInfo.setFilter(filterInfo); 14 BankDelegateTempCollection TempCollection = BankDelegateTempFactory.getRemoteInstance().getBankDelegateTempCollection(viewInfo); 15
2、多表查询,有过滤条件和排序
1 SelectorItemCollection sic = new SelectorItemCollection(); 2 sic.add("id"); 3 sic.add("number"); 4 sic.add("sellProject.id"); 5 sic.add("sellProject.name"); 6 sic.add("room.name"); 7 sic.add("customer.name"); 8 sic.add("bank.name"); 9 sic.add("bankAccount"); 10 sic.add("delegateAmount"); 11 sic.add("deductFlag"); 12 sic.add("appRevBillEntry.id"); 13 sic.add("appRevBillEntry.tenBillOtherPay.*"); 14 sic.add("tenancyBill.name"); 15 BankDelegateRecordInfo rec = (BankDelegateRecordInfo) BankDelegateRecordFactory.getRemoteInstance().getValue(new ObjectUuidPK(id), sic);
3、sql查询
1 // 更新合同收款明细的标志位 2 String sql = "select t2.fid sellProjectId from t_ten_bankdelegaterecord t1 left join T_SHE_SellProject t2 on t1.fsellprojectid = t2.fid where t1.fid='"+id+"'"; 3 IRowSet rs = SQLDataAccessFactory.getRemoteInstance().getRowSet(sql); 4 5 if(rs!=null && rs.size()>0) 6 { 7 while(rs.next()) 8 { 9 String sellProjectId = rs.getString("sellProjectId"); 10 BankDelegateExListFacadeFactory.getRemoteInstance().updateContrator(sellProjectId,null); 11 } 12 }
4、更新表的部分字段
1 SelectorItemCollection sit =new SelectorItemCollection(); 2 sit.add("bizDate"); 3 sit.add("lastUpdateUser"); 4 billInfo.setBizDate(new Date()); 5 billInfo.setLastUpdateUser(SysContext.getSysContext().getCurrentUserInfo()); 6 FDCReceivingBillFactory.getRemoteInstance().updatePartial(billInfo,sit);
5、sql更新表
1 String sql_X = "update T_TEN_TenancyRoomPayListEntry set fcollectionflag = null,cfisexecuted='0' where fcollectionflag = 'X' and fid = '" + tenancyRoomPayListID + "'"; 2 System.out.println("-----房屋租金-----sql_X执行终止回盘操作:"+sql_X); 3 DbUtil.execute(ctx, sql_X);
6、Oql删除所有
1 ModelFactory.getRemoteInstance().delete("where id is not null");
7、新增
1 //客户端sql插入 2 int row_num = SqlFacadeFactory.getRemoteInstance().executeSql(sql);