/**
   * 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;
 }
Esempio n. 4
0
 /* (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();
   }
 }
Esempio n. 5
0
 public boolean delUser(String userId) {
   User user = hibernateTemplate.get(User.class, userId);
   try {
     hibernateTemplate.delete(user);
   } catch (Exception e) {
     result = false;
   }
   return result;
 }
Esempio n. 6
0
 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);
       }
     }
   }
 }
Esempio n. 9
0
 @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);
 }
Esempio n. 11
0
 @Override
 public void delete(Naryad entity) {
     ht.delete(entity);
 }
Esempio n. 12
0
 /**
  * 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);
 }
Esempio n. 14
0
 @Override
 public void delete(Loan loan) {
   template.delete(loan);
 }
Esempio n. 15
0
 public void delete(int id) {
   Object obj = hibernateTemplate.get(clazz, id);
   if (obj != null) {
     hibernateTemplate.delete(obj);
   }
 }
Esempio n. 16
0
 public void delete(Authorities authorities) {
   hibernateTemplate.delete(authorities);
 }
Esempio n. 17
0
 @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);
 }
Esempio n. 19
0
 @Override
 public void remove(E entity) throws InstanceNotFoundException {
   ht.delete(entity);
 }
Esempio n. 20
0
 @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);
 }
Esempio n. 22
0
 public void deleteFaculty(final int facultyId) {
   Faculty faculty = getFaculty(facultyId);
   if (faculty != null) hibernateTemplate.delete(faculty);
 }
Esempio n. 23
0
 @Override
 public void delete(GroupHistory gh) {
   ht.delete(gh);
 }
Esempio n. 24
0
 public void delete(Manager manager) {
   hibernateTemplate.delete(manager);
 }
Esempio n. 25
0
 /** {@inheritDoc} */
 public void remove(PK id) {
   hibernateTemplate.delete(this.get(id));
 }
 @Transactional(readOnly = false)
 public void deleteTestTopic(TestStep t) {
   hibernateTemplate.delete(t);
 }
Esempio n. 27
0
 /**
  * 實作刪除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);
 }