List of usage examples for org.hibernate Session enableFetchProfile
void enableFetchProfile(String name) throws UnknownProfileException;
From source file:com.mycompany.CRMFly.hibernateAccess.DailyDAOImpl.java
@Override public List<Calls> getCallsforTask(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("tasks-with-calls"); Daily task = (Daily) sess.get(Daily.class, id); return task.getCallsConnectedWithTask(); }
From source file:com.mycompany.CRMFly.hibernateAccess.DailyDAOImpl.java
@Override public List<Contacts> getContactsforTask(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("tasks-with-contacts"); Daily task = (Daily) sess.get(Daily.class, id); return task.getContactsConnectedWithTask(); }
From source file:com.mycompany.CRMFly.hibernateAccess.DocumentsDAOImpl.java
@Override public void addDocument(Documents document) { sessionFactory.getCurrentSession().save(document); List<Contracts> temp;/*from ww w. ja va 2 s .com*/ List<Payments> temp2 = document.getPaymentsOnDocument(); List<Shipments> temp3 = document.getShipmentsOnDocument(); List<Clients> temp4 = document.getClients(); if (temp4 != null && temp4.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("documents-with-clients"); temp4 = clientsDAO.getFromProxy(temp4); for (Clients client : temp4) { client.getDocuments().add(document); clientsDAO.changeClient(client); } } if (temp2 != null && temp2.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("documents-with-payments"); temp2 = paymentsDAO.getFromProxy(temp2); for (Payments payment : temp2) { payment.setDocumentOnPayment(document); paymentsDAO.changePayment(payment); } } if (temp3 != null && temp3.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("documents-with-shipments"); temp3 = shipmentsDAO.getFromProxy(temp3); for (Shipments shipment : temp3) { shipment.getDocumentsOnShipment().add(document); shipmentsDAO.changeShipment(shipment); } } }
From source file:com.mycompany.CRMFly.hibernateAccess.DocumentsDAOImpl.java
@Override public void removeDocument(Documents document) { if (null != document) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); document = (Documents) sess.get(Documents.class, document.getId()); List<Contracts> temp; List<Payments> temp2 = document.getPaymentsOnDocument(); List<Shipments> temp3 = document.getShipmentsOnDocument(); List<Clients> temp4 = document.getClients(); if (temp4 != null && temp4.size() != 0) { sess.enableFetchProfile("documents-with-clients"); temp4 = clientsDAO.getFromProxy(temp4); for (Clients client : temp4) { client.getDocuments().remove(document); sess.update(client);/*from w w w . j a va 2s . co m*/ } } if (temp2 != null && temp2.size() != 0) { sess.enableFetchProfile("documents-with-payments"); temp2 = paymentsDAO.getFromProxy(temp2); for (Payments payment : temp2) { payment.setDocumentOnPayment(null); sess.update(payment); } } if (temp3 != null && temp3.size() != 0) { sess.enableFetchProfile("documents-with-shipments"); temp3 = shipmentsDAO.getFromProxy(temp3); for (Shipments shipment : temp3) { shipment.getDocumentsOnShipment().remove(document); sess.update(shipment); } } sess.update(document); sessionFactory.getCurrentSession().delete(document); } }
From source file:com.mycompany.CRMFly.hibernateAccess.DocumentsDAOImpl.java
@Override public Contracts getContractOnDocument(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("documents-with-contracts"); Documents document = (Documents) sess.get(Documents.class, id); return document.getContract(); }
From source file:com.mycompany.CRMFly.hibernateAccess.DocumentsDAOImpl.java
@Override public List<Clients> getSignersOfDocument(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("documents-with-clients"); Documents document = (Documents) sess.get(Documents.class, id); return document.getClients(); }
From source file:com.mycompany.CRMFly.hibernateAccess.DocumentsDAOImpl.java
@Override public List<Payments> getPaymentsOnDocument(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("documents-with-payments"); Documents document = (Documents) sess.get(Documents.class, id); return document.getPaymentsOnDocument(); }
From source file:com.mycompany.CRMFly.hibernateAccess.DocumentsDAOImpl.java
@Override public List<Shipments> getShipmentsOnDocument(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("documents-with-shipments"); Documents document = (Documents) sess.get(Documents.class, id); return document.getShipmentsOnDocument(); }
From source file:com.mycompany.CRMFly.hibernateAccess.EmployeesDAOImpl.java
@Override public void addEmployee(Employees employee) { sessionFactory.getCurrentSession().save(employee); List<Contracts> temp = employee.getResponsibleForContracts(); List<Projects> temp2 = employee.getParticipate(); List<Daily> temp3 = employee.getTasks(); if (temp != null && temp.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("employees-with-contracts"); temp = contractsDAO.getFromProxy(temp); for (Contracts contract : temp) { contract.setResponsibleManager(employee); contractsDAO.changeContract(contract); }/*from ww w . ja va 2s. c o m*/ } if (temp2 != null && temp2.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("employees-with-projects"); temp2 = projectsDAO.getFromProxy(temp2); for (Projects project : temp2) { project.getParticipants().add(employee); projectsDAO.changeProject(project); } } if (employee.getResponsibleForProjects() != null) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("employees-with-projects"); temp2 = projectsDAO.getFromProxy(employee.getResponsibleForProjects()); for (Projects project : temp2) { project.setResponsibleManager(employee); projectsDAO.changeProject(project); } } if (temp3 != null && temp3.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("employees-with-tasks"); temp3 = dailyDAO.getFromProxy(temp3); for (Daily task : temp3) { task.setImplementer(employee); dailyDAO.changeTask(task); } } }
From source file:com.mycompany.CRMFly.hibernateAccess.EmployeesDAOImpl.java
@Override public void removeEmployee(Employees employee) { if (null != employee) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); employee = (Employees) sess.get(Employees.class, employee.getId()); List<Contracts> temp = employee.getResponsibleForContracts(); List<Projects> temp2 = employee.getParticipate(); List<Daily> temp3 = employee.getTasks(); List<Employees> subordinades = employee.getSubordinates(); if (temp != null && temp.size() != 0) { sess.enableFetchProfile("employees-with-contracts"); temp = contractsDAO.getFromProxy(temp); for (Contracts contract : temp) { contract.setResponsibleManager(null); sess.update(contract);/* w w w .jav a 2 s . c o m*/ } } if (temp2 != null && temp2.size() != 0) { sess.enableFetchProfile("employees-with-projects"); temp2 = projectsDAO.getFromProxy(temp2); for (Projects project : temp2) { project.getParticipants().remove(employee); sess.update(project); } } if (employee.getResponsibleForProjects() != null) { sess.enableFetchProfile("employees-with-projects"); temp2 = projectsDAO.getFromProxy(employee.getResponsibleForProjects()); for (Projects project : temp2) { project.setResponsibleManager(null); sess.update(project); } } if (temp3 != null && temp3.size() != 0) { sess.enableFetchProfile("employees-with-tasks"); temp3 = dailyDAO.getFromProxy(temp3); for (Daily task : temp3) { task.setImplementer(null); sess.update(task); } } if (subordinades != null && subordinades.size() != 0) { for (Employees empl : subordinades) { empl.setManager(null); sess.update(empl); } } sess.update(employee); sessionFactory.getCurrentSession().delete(employee); } }