コード例 #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);
      }
    }
  }