List of usage examples for org.hibernate Session enableFetchProfile
void enableFetchProfile(String name) throws UnknownProfileException;
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
public void deleteDocumentConnection(Organisations customer, Documents document) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("clients-with-documents"); customer = (Organisations) sess.load(Organisations.class, customer.getId()); customer.getDocuments().remove(document); sess.update(customer);/* w ww. ja v a2 s .c o m*/ document = (Documents) sess.load(Documents.class, document.getId()); document.getClients().add(customer); sess.update(document); }
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
public void deletePaymentFrom(Organisations customer, Payments payment) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("clients-with-paymentsFrom"); customer = (Organisations) sess.load(Organisations.class, customer.getId()); customer.getPaymentsFromClient().remove(payment); sess.update(customer);/*from w w w. ja va2 s .c om*/ payment = (Payments) sess.load(Payments.class, payment.getId()); payment.setPayerOfPayment(null); paymentsDAO.removePayment(payment); }
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
public void deletePaymentTo(Organisations customer, Payments payment) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("clients-with-payments"); customer = (Organisations) sess.load(Organisations.class, customer.getId()); customer.getPaymentsToClient().remove(payment); sess.update(customer);/*w w w . j a v a 2 s . c o m*/ payment = (Payments) sess.load(Payments.class, payment.getId()); payment.setReceiverOfPayment(null); paymentsDAO.removePayment(payment); }
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
public void deleteProductConnection(Organisations organisation, Products product) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("organisations-with-products"); organisation = (Organisations) sess.load(Organisations.class, organisation.getId()); organisation.getProducts().remove(product); sess.update(organisation);/* w ww . j a v a2 s . c o m*/ product = (Products) sess.load(Products.class, product.getId()); product.getManufacturers().remove(organisation); sess.update(product); }
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
public void deleteContactConnection(Organisations organisation, Contacts contact) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("organisations-with-contacts"); organisation = (Organisations) sess.load(Organisations.class, organisation.getId()); organisation.getContacts().remove(contact); sess.update(organisation);// w w w . ja va2 s . c o m contact = (Contacts) sess.load(Contacts.class, contact.getId()); contact.setOrganisation(null); sess.update(contact); }
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
@Override public void removeOrganisation(Organisations organisation) { if (null != organisation) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); organisation = (Organisations) sessionFactory.getCurrentSession().get(Organisations.class, organisation.getId());//from ww w . jav a2 s . c o m List<Contacts> temp = organisation.getContacts(); List<ParticipantsInProject> temp2 = organisation.getParticipateInProjects(); List<Products> temp3 = organisation.getProducts(); List<Documents> temp4 = organisation.getDocuments(); List<Payments> temp5 = organisation.getPaymentsFromClient(); List<Payments> temp6 = organisation.getPaymentsToClient(); List<ContragentsInContract> temp7 = organisation.getParticipantInContracts(); List<ContragentsInShipment> temp8 = organisation.getParticipantInShipments(); List<Requests> temp9 = organisation.getRequests(); List<Payments> temp10 = organisation.getServedPayments(); if (temp4 != null && temp4.size() != 0) { sess.enableFetchProfile("clients-with-documents"); temp4 = documentsDAO.getFromProxy(temp4); for (Documents doc : temp4) { doc.getClients().remove(organisation); sess.update(doc); } } if (temp5 != null && temp5.size() != 0) { sess.enableFetchProfile("clients-with-paymentsFrom"); temp5 = paymentsDAO.getFromProxy(temp5); for (Payments payment : temp5) { payment.setPayerOfPayment(null); sess.update(payment); } } if (temp6 != null && temp6.size() != 0) { sess.enableFetchProfile("clients-with-payments"); temp6 = paymentsDAO.getFromProxy(organisation.getPaymentsToClient()); for (Payments payment : temp6) { payment.setReceiverOfPayment(null); sess.update(payment); } } if (temp != null && temp.size() != 0) { sess.enableFetchProfile("organisations-with-contacts"); temp = contactsDAO.getFromProxy(temp); for (Contacts contact : temp) { contact.setOrganisation(null); sess.update(contact); } } if (temp3 != null && temp3.size() != 0) { sess.enableFetchProfile("organisations-with-products"); temp3 = productsDAO.getFromProxy(temp3); for (Products product : temp3) { product.getManufacturers().remove(organisation); sess.update(product); } } if (temp2 != null && temp2.size() != 0) { for (ParticipantsInProject project : temp2) { sess.delete(project); } } if (temp7 != null && temp7.size() != 0) { for (ContragentsInContract contragent : temp7) { sess.delete(contragent); } } if (temp8 != null && temp8.size() != 0) { for (ContragentsInShipment contragent : temp8) { sess.delete(contragent); } } if (temp9 != null && temp9.size() != 0) { sess.enableFetchProfile("clients-with-requests"); temp9 = requestsDAO.getFromProxy(organisation.getRequests()); for (Requests request : temp9) { request.setRequester(null); sess.update(request); } } if (temp10 != null && temp10.size() != 0) { sess.enableFetchProfile("organisations-with-servedpay"); temp10 = paymentsDAO.getFromProxy(organisation.getServedPayments()); for (Payments payment : temp10) { payment.setBank(null); sess.update(payment); } } sess.update(organisation); sessionFactory.getCurrentSession().delete(organisation); } }
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
@Override public List<Contacts> getContactsWithOrganisation(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("organisations-with-contacts"); Organisations organisation = (Organisations) sess.get(Organisations.class, id); return organisation.getContacts(); }
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
@Override public List<Products> getManufacturedProducts(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("organisations-with-products"); Organisations organisation = (Organisations) sess.get(Organisations.class, id); return organisation.getProducts(); }
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
@Override public Organisations getProjectForPosition(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("orgs-with-projects"); ParticipantsInProject organisation = (ParticipantsInProject) sess.get(ParticipantsInProject.class, id); return organisation.getOrganisation(); }
From source file:com.mycompany.CRMFly.hibernateAccess.OrganisationsDAOImpl.java
public List<Projects> getProjectsForOrganisation(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("orgs-with-projects"); Organisations organisation = (Organisations) sess.get(Organisations.class, id); List<Projects> returnList = new ArrayList<Projects>(); List<ParticipantsInProject> party = organisation.getParticipateInProjects(); for (ParticipantsInProject par : party) { returnList.add(par.getProject()); }//from www . ja v a 2 s . com return returnList; }