Пример #1
0
 public List<Clients> getFromProxy(List<Clients> proxy) {
   Disjunction or = Restrictions.disjunction();
   for (Clients pr : proxy) {
     or.add(Restrictions.eq("id", pr.getId()));
   }
   return sessionFactory.getCurrentSession().createCriteria(Clients.class).add(or).list();
 }
Пример #2
0
 @Override
 public List<ContragentsInShipment> getParticipationInShipments(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("clients-with-rolesShip");
   Clients client = (Clients) sess.get(Clients.class, id);
   return client.getParticipantInShipments();
 }
Пример #3
0
 @Override
 public List<Requests> getRequestsFromClient(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("clients-with-requests");
   Clients client = (Clients) sess.get(Clients.class, id);
   return client.getRequests();
 }
Пример #4
0
 public List<Shipments> getShipmentsForClient(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("clients-with-rolesShip");
   sess.enableFetchProfile("clients-with-shipments");
   Clients client = (Clients) sess.get(Clients.class, id);
   List<Shipments> returnList = new ArrayList<Shipments>();
   List<ContragentsInShipment> shipList = client.getParticipantInShipments();
   for (ContragentsInShipment con : shipList) {
     returnList.add(con.getShipment());
   }
   return returnList;
 }
Пример #5
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);
      }
    }
  }