基于元数据的持久化服务接口实现类:
package nc.md.persist.framework.imp; import java.util.Collection; import nc.md.data.access.NCObject; import nc.md.data.criterion.QueryCondition; import nc.md.model.MetaDataException; import nc.md.persist.framework.IMDPersistenceQueryService; import nc.md.persist.framework.IMDPersistenceService; import nc.vo.pub.CircularlyAccessibleValueObject; /** * 基于元数据的持久化服务接口实现类 */ public class MDPersistenceServiceImp implements IMDPersistenceService, IMDPersistenceQueryService { public String saveBill(Object billVO) throws MetaDataException { return (new MDBaseDAO()).saveBill(billVO, false); } public String[] saveBill(CircularlyAccessibleValueObject[] billVos) throws MetaDataException { return (new MDBaseDAO()).saveBill(billVos, false); } public String saveBillWithRealDelete(Object billVO) throws MetaDataException { return (new MDBaseDAO()).saveBill(billVO, true); } public String[] saveBillWithRealDelete( CircularlyAccessibleValueObject[] billVos) throws MetaDataException { return (new MDBaseDAO()).saveBill(billVos, true); } public String[] saveBillWithRealDelete(NCObject[] billVos) throws MetaDataException { return (new MDBaseDAO()).saveBill(billVos, true); } public String saveBillWithRealDelete(NCObject billVo) throws MetaDataException { String[] pks = (new MDBaseDAO()).saveBill(new NCObject[] { billVo }, true); if (pks != null && pks.length > 0) return pks[0]; return null; } public String[] saveBill(NCObject[] billVos) throws MetaDataException { return (new MDBaseDAO()).saveBill(billVos, false); } public String saveBill(NCObject billVo) throws MetaDataException { String[] pks = (new MDBaseDAO()).saveBill(new NCObject[] { billVo }, false); if (pks != null && pks.length > 0) return pks[0]; return null; } /** * 删除单据 * * @param billVo * @throws MetaDataException */ public void deleteBill(Object billVo) throws MetaDataException { (new MDBaseDAO()).deleteBill(billVo); } public NCObject queryBillOfNCObjectByPK(Class voClass, String billPK) throws MetaDataException { return (new MDBaseDAO()) .queryBillOfNCObjectByPK(voClass, billPK, false); } @Override public NCObject queryBillOfNCObjectByPKWithDR(Class voClass, String billPK, boolean ignoreDrEqual1) throws MetaDataException { return (new MDBaseDAO()).queryBillOfNCObjectByPK(voClass, billPK, ignoreDrEqual1); } /** * 根据PK查询单据,返回实际的VO * * @param voClass * @param billPK * @param bLazyLoad * 是否懒加载 * @return * @throws MetaDataException */ public <T> T queryBillOfVOByPK(Class<T> voClass, String billPK, boolean bLazyLoad) throws MetaDataException { return (T) (new MDBaseDAO()).queryBillOfVOByPK(voClass, billPK, bLazyLoad); } public Collection queryBillOfVOByPKs(Class voClass, String[] billPKs, boolean bLazyLoad) throws MetaDataException { return (new MDBaseDAO()) .queryBillOfVOByPKs(voClass, billPKs, bLazyLoad); } @Override public Object[] queryBillOfVOByPKsWithOrder(Class voClass, String[] billPKs, boolean lazyLoad) throws MetaDataException { return (new MDBaseDAO()).queryBillOfVOByPKsWithOrder(voClass, billPKs, lazyLoad); } @Override public Object[] queryBillOfVOByPKsWithOrder(Class voClass, String[] billPKs, String[] subEntityName) throws MetaDataException { return (new MDBaseDAO()).queryBillOfVOByPKsWithOrder(voClass, billPKs, subEntityName); } /** * 提供面向模型的查询 * * @param session * @param bLazyLoad * @return * @throws MetaDataException */ public Collection queryBillOfVOByCond(QueryCondition condition, boolean bLazyLoad) throws MetaDataException { return (new MDBaseDAO()) .queryBillOfVOByCond(condition, bLazyLoad, null); } public Collection queryBillOfVOByCondWithOrder(QueryCondition condition, boolean bLazyLoad, String[] orderPaths) throws MetaDataException { return (new MDBaseDAO()).queryBillOfVOByCond(condition, bLazyLoad, orderPaths); } /** * @param voClass * 主子表VO传主表VO类,一般VO直接传VO类 * @param whereCondStr * @return */ public NCObject[] queryBillOfNCObjectByCond(Class voClass, String whereCondStr, boolean bLazyLoad) throws MetaDataException { return (new MDBaseDAO()).queryBillOfNCObjectByCond(voClass, whereCondStr, bLazyLoad, null); } /** * 根据where条件查询单据,返回实际的VO集合(List) * * @param voClass * @param whereCondStr * @param bLazyLoad * 是否懒加载 * @return * @throws MetaDataException */ public Collection queryBillOfVOByCond(Class voClass, String whereCondStr, boolean bLazyLoad) throws MetaDataException { return (new MDBaseDAO()).queryBillOfVOByCond(voClass, whereCondStr, false, bLazyLoad, null); } public Collection queryBillOfVOByCond(Class voClass, String whereCondStr, boolean ignoreDrEqual1, boolean bLazyLoad) throws MetaDataException { return (new MDBaseDAO()).queryBillOfVOByCond(voClass, whereCondStr, ignoreDrEqual1, bLazyLoad, null); } @Override public <E> Collection<E> queryBusiVOByCond(Class<E> voClass, String[] tableNames, String whereCondStr, boolean ignoreDrEqual1, boolean lazyLoad, String[] orderPaths) throws MetaDataException { return (new MDBaseDAO()).queryBillOfVOByCond(voClass, tableNames, whereCondStr, ignoreDrEqual1, lazyLoad, orderPaths); } @Override public <E> Collection<E> queryBusiVOByFromAndCond(Class<E> voClass, String fromTableSql, String whereCondStr, boolean lazyLoad, String[] orderPaths) throws MetaDataException { return (new MDBaseDAO()).queryBillOfVOByFromAndCond(voClass, fromTableSql, whereCondStr, lazyLoad, orderPaths); } @Override public Collection queryBillOfVOByCondWithOrder(Class voClass, String whereCondStr, boolean ignoreDrEqual1, boolean lazyLoad, String[] orderPaths) throws MetaDataException { return (new MDBaseDAO()).queryBillOfVOByCond(voClass, whereCondStr, ignoreDrEqual1, lazyLoad, orderPaths); } @Override public Collection queryBillOfVOByCondWithOrder(Class voClass, String whereCondStr, boolean ignoreDrEqual1, String[] sunEntityPaths, String[] orderPaths) throws MetaDataException { return (new MDBaseDAO()).queryBillOfVOByCond(voClass, whereCondStr, ignoreDrEqual1, sunEntityPaths, orderPaths); } public void deleteBill(NCObject ncObj) throws MetaDataException { (new MDBaseDAO()).deleteBill(new NCObject[] { ncObj }); } public void deleteBill(NCObject[] ncObjs) throws MetaDataException { (new MDBaseDAO()).deleteBill(ncObjs); } /** * 从数据库删除(真删) * * @param billVo * @throws MetaDataException */ public void deleteBillFromDB(Object billVo) throws MetaDataException { (new MDBaseDAO()).deleteBillFromDB(billVo); } /** * 从数据库删除(真删) * * @param billVos * @throws MetaDataException */ public void deleteBillFromDB(CircularlyAccessibleValueObject[] billVos) throws MetaDataException { (new MDBaseDAO()).deleteBillFromDB(billVos); } /** * 从数据库删除(真删) * * @param billVos * @throws MetaDataException */ public void deleteBillFromDB(NCObject[] billVos) throws MetaDataException { (new MDBaseDAO()).deleteBillFromDB(billVos); } /** * 从数据库删除(真删) * * @param billVos * @throws MetaDataException */ public void deleteBillFromDB(NCObject billVo) throws MetaDataException { (new MDBaseDAO()).deleteBillFromDB(new NCObject[] { billVo }); } @Override public NCObject[] queryBillOfNCObjectByCond(Class voClass, String whereCondStr, String[] filtAttrNames, boolean lazyLoad) throws MetaDataException { return new MDBaseDAO().queryBillOfVOByCond(voClass, whereCondStr, filtAttrNames, false, lazyLoad); } @Override public NCObject queryBillOfNCObjectByPK(Class voClass, String billPK, String[] filtAttrNames, boolean lazyLoad) throws MetaDataException { NCObject[] objs = (new MDBaseDAO()).queryBillOfNCObjectByPKs(voClass, new String[] { billPK }, filtAttrNames, lazyLoad); return objs == null || objs.length == 0 ? null : objs[0]; } @Override public NCObject[] queryBillOfNCObjectByPKs(Class voClass, String[] billPKs, String[] filtAttrNames, boolean lazyLoad) throws MetaDataException { return (new MDBaseDAO()).queryBillOfNCObjectByPKs(voClass, billPKs, filtAttrNames, lazyLoad); } @Override public void deleteBillByPK(Class voClass, String pk) throws MetaDataException { new MDBaseDAO().deleteBillByPK(voClass, new String[] { pk }); } @Override public void deleteBillByPK(Class voClass, String[] pks) throws MetaDataException { new MDBaseDAO().deleteBillByPK(voClass, pks); } @Override public void updateBillWithAttrs(NCObject[] billVos, String[] filtAttrNames) throws MetaDataException { new MDBaseDAO().updateBillWithAttrs(billVos, filtAttrNames); } @Override public void updateBillWithAttrs(Object[] billVo, String[] filtAttrNames) throws MetaDataException { if (billVo == null || billVo.length == 0) { return; } new MDBaseDAO().updateBillWithAttrs(MDPersistUtil.getNCObject(billVo), filtAttrNames); } }