示例#1
0
 @Override
 public List<Payments> getPaymentsFromClient(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("clients-with-paymentsFrom");
   Clients client = (Clients) sess.get(Clients.class, id);
   return client.getPaymentsFromClient();
 }
示例#2
0
  @Override
  public void addClient(Clients client) {
    List<Documents> temp = client.getDocuments();
    List<Payments> temp2 = client.getPaymentsFromClient();
    sessionFactory.getCurrentSession().save(client);

    // add links to documents
    if (temp != null && temp.size() != 0) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("clients-with-documents");
      temp = documentsDAO.getFromProxy(temp);
      for (Documents doc : temp) {
        doc.getClients().add(client);
        documentsDAO.changeDocument(doc);
      }
    }

    if (temp2 != null && temp2.size() != 0) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("clients-with-payments");
      temp2 = paymentsDAO.getFromProxy(temp2);
      for (Payments payment : temp2) {
        payment.setPayerOfPayment(client);
        paymentsDAO.changePayment(payment);
      }
    }

    if (client.getPaymentsToClient() != null) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("clients-with-payments");
      temp2 = paymentsDAO.getFromProxy(client.getPaymentsToClient());
      for (Payments payment : temp2) {
        payment.setReceiverOfPayment(client);
        paymentsDAO.changePayment(payment);
      }
    }
  }