/** * Tests <code>{@link CopilotProjectDAOImpl#retrieveAll()}</code> method. * * @throws CopilotDAOException if any error occurs */ @Test public void testRetrieveAll2() throws CopilotDAOException { CopilotProfile copilotProfile1 = TestHelper.createCopilotProfile(); CopilotProject copilotProject1 = TestHelper.createCopilotProject(); TestHelper.persistCopilotProjectDependencies( hibernateTemplate, copilotProfile1, copilotProject1); hibernateTemplate.save(copilotProject1); CopilotProfile copilotProfile2 = TestHelper.createCopilotProfile(); CopilotProject copilotProject2 = TestHelper.createCopilotProject(); TestHelper.persistCopilotProjectDependencies( hibernateTemplate, copilotProfile2, copilotProject2); hibernateTemplate.save(copilotProject2); List<CopilotProject> result = instance.retrieveAll(); Assert.assertEquals("Two entities were expected.", 2, result.size()); assertCopilotProject(copilotProject1, result.get(0)); assertCopilotProject(copilotProject2, result.get(1)); hibernateTemplate.delete(copilotProject1); result = instance.retrieveAll(); Assert.assertEquals("One entity was expected.", 1, result.size()); assertCopilotProject(copilotProject2, result.get(0)); hibernateTemplate.delete(copilotProject2); Assert.assertEquals("No entities were expected.", 0, instance.retrieveAll().size()); }
protected void handleActionRequestInternal(ActionRequest request, ActionResponse response) throws Exception { Integer relTypeId = null; try { relTypeId = Integer.valueOf(request.getParameter("relTypeId")); } catch (Exception ex) { throw new RuntimeException( "Error getting relationship type ID from request: " + ex.getMessage(), ex); } CatalogEntryRelationshipType relType = getCatalogEntryRelationshipTypeDao().getById(relTypeId); if (relType == null) { throw new RuntimeException("Couldn't find relationship type for id: " + relTypeId); } HibernateTemplate templ = getCatalogEntryRelationshipTypeDao().getHibernateTemplate(); CatalogEntryRoleType roleTypeA = relType.getRoleTypeA(); roleTypeA.setRelationshipType(null); relType.setRoleTypeA(null); templ.save(roleTypeA); CatalogEntryRoleType roleTypeB = relType.getRoleTypeB(); roleTypeB.setRelationshipType(null); relType.setRoleTypeB(null); templ.save(roleTypeB); templ.save(relType); templ.delete(roleTypeA); templ.delete(roleTypeB); templ.delete(relType); getCatalogEntryRelationshipTypeDao().getHibernateTemplate().flush(); getUserModel().setCurrentRelationshipType(null); }
@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public boolean delete(Guardian guardian) { hibernateTemplate.delete(guardian); hibernateTemplate.flush(); return true; }
/* (non-Javadoc) * @see cn.believeus.dao.IBaseDao#delete(java.lang.Class, java.lang.String, java.lang.Object) */ @Override public void delete(Class<?> clazz, String property, final Object value) { HibernateTemplate ht = getHibernateTemplate(); List<?> objectList = this.findObjectList(clazz, property, value); for (Object entity : objectList) { ht.delete(entity); ht.flush(); } }
public boolean delUser(String userId) { User user = hibernateTemplate.get(User.class, userId); try { hibernateTemplate.delete(user); } catch (Exception e) { result = false; } return result; }
public void delete(Consumable persistentInstance) { log.debug("deleting Consumable instance"); try { hibernateTemplate.delete(persistentInstance); log.debug("delete successful"); } catch (RuntimeException re) { log.error("delete failed", re); throw re; } }
public int deleletByid(int id) { BackDetail backDetail = new BackDetail(); backDetail.setBackDid(id); try { hibernateTemplate.delete(backDetail); } catch (Exception e) { e.printStackTrace(); return 0; } return 1; }
public void generateTransferRepay( List<InvestRepay> investRepays, Invest invest, double corpusRate) { for (Iterator iterator = investRepays.iterator(); iterator.hasNext(); ) { InvestRepay ir = (InvestRepay) iterator.next(); if (ir.getStatus().equals(RepayStatus.WAIT_REPAY_VERIFY) || ir.getStatus().equals(RepayStatus.OVERDUE) || ir.getStatus().equals(RepayStatus.BAD_DEBT)) { throw new RuntimeException( "investRepay with status " + RepayStatus.WAIT_REPAY_VERIFY + "exist!"); } else if (ir.getStatus().equals(RepayStatus.REPAYING)) { // 根据购买本金比例,生成债权还款信息 InvestRepay irNew = new InvestRepay(); try { BeanUtils.copyProperties(irNew, ir); } catch (Exception e) { throw new RuntimeException(e); } irNew.setId(IdGenerator.randomUUID()); irNew.setCorpus(ArithUtil.mul(ir.getCorpus(), corpusRate, 2)); irNew.setDefaultInterest(ArithUtil.mul(ir.getDefaultInterest(), corpusRate, 2)); irNew.setFee(ArithUtil.mul(ir.getFee(), corpusRate, 2)); irNew.setInterest(ArithUtil.mul(ir.getInterest(), corpusRate, 2)); irNew.setInvest(invest); // 修改原投资的还款信息 ir.setCorpus(ArithUtil.sub(ir.getCorpus(), irNew.getCorpus())); ir.setDefaultInterest(ArithUtil.sub(ir.getDefaultInterest(), irNew.getDefaultInterest())); ir.setFee(ArithUtil.sub(ir.getFee(), irNew.getFee())); ir.setInterest(ArithUtil.sub(ir.getInterest(), irNew.getInterest())); ht.merge(irNew); if (corpusRate == 1) { ht.delete(ir); iterator.remove(); } else { ht.update(ir); } } } }
@Override public void delete(int id) { GroupHistory gh = new GroupHistory(); gh.setId(id); ht.delete(gh); }
@Transactional(readOnly = false) public void deleteStat(Stat s) { hibernateTemplate.delete(s); }
@Override public void delete(Naryad entity) { ht.delete(entity); }
/** * delete user * * @param user user reference */ @Override public User delete(User user) { hibernateTemplate.delete(user); return user; }
@Transactional(readOnly = false) public void deleteStatCategory(StatCategory sc) { hibernateTemplate.delete(sc); }
@Override public void delete(Loan loan) { template.delete(loan); }
public void delete(int id) { Object obj = hibernateTemplate.get(clazz, id); if (obj != null) { hibernateTemplate.delete(obj); } }
public void delete(Authorities authorities) { hibernateTemplate.delete(authorities); }
@Transactional @Override public void delete(LookFor lookFor) { template.delete(lookFor); template.flush(); }
@Override public void removeState(Long id) { Object record = hibernateTemplate.load(State.class, id); hibernateTemplate.delete(record); }
@Override public void remove(E entity) throws InstanceNotFoundException { ht.delete(entity); }
@Override public void delete(Goodsinfo goodsinfo) { // TODO Auto-generated method stub if (goodsinfo != null) mysqlhibernateTemplete.delete(goodsinfo); else logger.error("删除商品对象为null!"); }
public void deleteFieldValue(FieldValue fieldValue) { hibernateTemplate.delete(fieldValue); }
public void deleteFaculty(final int facultyId) { Faculty faculty = getFaculty(facultyId); if (faculty != null) hibernateTemplate.delete(faculty); }
@Override public void delete(GroupHistory gh) { ht.delete(gh); }
public void delete(Manager manager) { hibernateTemplate.delete(manager); }
/** {@inheritDoc} */ public void remove(PK id) { hibernateTemplate.delete(this.get(id)); }
@Transactional(readOnly = false) public void deleteTestTopic(TestStep t) { hibernateTemplate.delete(t); }
/** * 實作刪除TeacherStayTime清單 * * @param tsts tw.edu.chit.model.Empl object */ public void deleteStayTimeByEmpl(List<TeacherStayTime> tsts) { HibernateTemplate ht = getHibernateTemplate(); for (TeacherStayTime tst : tsts) ht.delete(tst); // Empl empl = tsts.get(0).getEmpl(); // empl.setStayTime(null); }