List of usage examples for org.hibernate Session enableFetchProfile
void enableFetchProfile(String name) throws UnknownProfileException;
From source file:com.mycompany.CRMFly.hibernateAccess.ContactsDAOImpl.java
public void deleteTaskConnection(Contacts contact, Daily task) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contacts-with-tasks"); contact = (Contacts) sess.get(Contacts.class, contact.getId()); contact.getTasks().remove(task);/*w ww . jav a 2 s .com*/ sess.update(contact); task = (Daily) sess.get(Daily.class, task.getId()); task.getContactsConnectedWithTask().remove(contact); sess.update(task); }
From source file:com.mycompany.CRMFly.hibernateAccess.ContactsDAOImpl.java
public void deleteContractConnection(Contacts contact, Contracts contract) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contacts-with-contracts"); contact = (Contacts) sess.load(Contacts.class, contact.getId()); contact.getContractsConnectedWithContact().remove(contract); sess.update(contact);//from w w w. jav a 2 s. c o m contract = (Contracts) sess.load(Contracts.class, contract.getId()); contract.getAddContacts().remove(contact); sess.update(contract); }
From source file:com.mycompany.CRMFly.hibernateAccess.ContactsDAOImpl.java
@Override public void removeContact(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); Contacts contact = (Contacts) sess.get(Contacts.class, id); List<Calls> temp = contact.getCalls(); List<Daily> temp2 = contact.getTasks(); List<Contracts> temp3 = contact.getContractsConnectedWithContact(); boolean first = (temp != null && temp.size() != 0) ? true : false; boolean second = (temp2 != null && temp2.size() != 0) ? true : false; boolean third = (temp3 != null && temp3.size() != 0) ? true : false; if (first) {/*from www .j a va2 s.c o m*/ sess.enableFetchProfile("contacts-with-calls"); temp = callsDAO.getFromProxy(temp); for (Calls call : temp) { callsDAO.removeCall(call); } } if (second) { sess.enableFetchProfile("contacts-with-tasks"); temp2 = dailyDAO.getFromProxy(temp2); for (Daily task : temp2) { task.getContactsConnectedWithTask().remove(contact); sess.update(task); } } if (third) { sess.enableFetchProfile("contacts-with-contracts"); temp3 = contractsDAO.getFromProxy(temp3); for (Contracts contract : temp3) { contract.getAddContacts().remove(contact); sess.update(contract); } } contact.setCalls(null); contact.setConnectedRequests(null); contact.setContractsConnectedWithContact(null); contact.setOrganisation(null); contact.setTasks(null); sess.update(contact); sessionFactory.getCurrentSession().delete(contact); }
From source file:com.mycompany.CRMFly.hibernateAccess.ContactsDAOImpl.java
@Override public List<Calls> getCallsOfContact(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contacts-with-calls"); Contacts contact = (Contacts) sess.get(Contacts.class, id); return contact.getCalls(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ContactsDAOImpl.java
@Override public List<Contracts> getContractsOfContact(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contacts-with-contracts"); Contacts contact = (Contacts) sess.get(Contacts.class, id); return contact.getContractsConnectedWithContact(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ContactsDAOImpl.java
@Override public List<Daily> getTasksForContact(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contacts-with-tasks"); Contacts contact = (Contacts) sess.get(Contacts.class, id); return contact.getTasks(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ContractsDAOImpl.java
@Override public void addContract(Contracts contract) { List<Contacts> contTemp = contract.getAddContacts(); List<Documents> docTemp = contract.getDocsForContract(); List<Payments> payTemp = contract.getPaymentsForContract(); List<ContragentsInContract> contrTemp = contract.getContragents(); List<PositionsInContract> prodTemp = contract.getProductPositions(); sessionFactory.getCurrentSession().save(contract); if (contTemp != null && contTemp.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contracts-with-contacts"); contTemp = contactsDAO.getFromProxy(contTemp); for (Contacts contact : contTemp) { contact.getContractsConnectedWithContact().add(contract); contactsDAO.changeContact(contact); }/*from w ww . ja va 2s . c o m*/ } if (payTemp != null && payTemp.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contracts-with-payments"); payTemp = paymentsDAO.getFromProxy(payTemp); for (Payments payment : payTemp) { payment.setContractOnPayment(contract); paymentsDAO.changePayment(payment); } } if (docTemp != null && docTemp.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contracts-with-documents"); docTemp = documentsDAO.getFromProxy(docTemp); for (Documents document : docTemp) { document.setContract(contract); documentsDAO.changeDocument(document); } } if (contrTemp != null && contrTemp.size() != 0) { for (ContragentsInContract contragent : contrTemp) { contragent.setContract(contract); sessionFactory.getCurrentSession().save(contragent); } } if (prodTemp != null && prodTemp.size() != 0) { prodTemp = contract.getProductPositions(); for (PositionsInContract position : prodTemp) { position.setContract(contract); sessionFactory.getCurrentSession().save(position); } } }
From source file:com.mycompany.CRMFly.hibernateAccess.ContractsDAOImpl.java
public void addContactConnection(Contracts contract, Contacts contact) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contracts-with-contacts"); contract.getAddContacts().add(contact); sess.update(contract);//from w w w . j a v a 2 s. com contact.getContractsConnectedWithContact().add(contract); sess.update(contact); }
From source file:com.mycompany.CRMFly.hibernateAccess.ContractsDAOImpl.java
public void addDocumentConnection(Contracts contract, Documents document) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contracts-with-documents"); contract.getDocsForContract().add(document); sess.update(contract);/*from w w w .j a v a 2s . c o m*/ document.setContract(contract); sess.update(contract); }
From source file:com.mycompany.CRMFly.hibernateAccess.ContractsDAOImpl.java
public void addPaymentConnection(Contracts contract, Payments payment) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("contracts-with-payments"); contract.getPaymentsForContract().add(payment); sess.update(contract);//from w w w. j a v a 2 s . c om payment.setContractOnPayment(contract); sess.update(contract); }