List of usage examples for org.hibernate Session enableFetchProfile
void enableFetchProfile(String name) throws UnknownProfileException;
From source file:com.mycompany.CRMFly.hibernateAccess.RequestsDAOImpl.java
@Override public List<Products> getAllProducts(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("requests-with-products"); Requests request = (Requests) sess.get(Requests.class, id); return request.getProducts(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ShipmentsDAOImpl.java
@Override public void addShipment(Shipments shipment) { sessionFactory.getCurrentSession().save(shipment); List<Documents> temp = shipment.getDocumentsOnShipment(); List<Payments> temp2 = shipment.getPayments(); List<PositionsInShipment> temp3 = shipment.getProductPositions(); List<ContragentsInShipment> temp4 = shipment.getContragents(); if (temp2 != null && temp2.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("shipments-with-payments"); temp2 = paymentsDAO.getFromProxy(temp2); for (Payments payment : temp2) { payment.setShipment(shipment); paymentsDAO.changePayment(payment); }//from w ww . j a v a 2 s. c o m } if (temp != null && temp.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("shipments-with-documents"); temp = documentsDAO.getFromProxy(temp); for (Documents document : temp) { document.getShipmentsOnDocument().add(shipment); documentsDAO.changeDocument(document); } } if (temp4 != null && temp4.size() != 0) { for (ContragentsInShipment contragent : temp4) { contragent.setShipment(shipment); sessionFactory.getCurrentSession().save(contragent); } } if (temp3 != null && temp3.size() != 0) { for (PositionsInShipment position : temp3) { position.setShipment(shipment); sessionFactory.getCurrentSession().save(position); } } }
From source file:com.mycompany.CRMFly.hibernateAccess.ShipmentsDAOImpl.java
@Override public void removeShipment(Shipments shipment) { if (null != shipment) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); shipment = (Shipments) sess.get(Shipments.class, shipment.getId()); List<Documents> temp = shipment.getDocumentsOnShipment(); List<Payments> temp2 = shipment.getPayments(); List<PositionsInShipment> temp3 = shipment.getProductPositions(); List<ContragentsInShipment> temp4 = shipment.getContragents(); if (temp2 != null && temp2.size() != 0) { sess.enableFetchProfile("shipments-with-payments"); temp2 = paymentsDAO.getFromProxy(temp2); for (Payments payment : temp2) { payment.setShipment(null); sess.update(payment);// w ww . j a v a 2 s . c o m } } if (temp != null && temp.size() != 0) { sess.enableFetchProfile("shipments-with-documents"); temp = documentsDAO.getFromProxy(temp); for (Documents document : temp) { document.getShipmentsOnDocument().remove(shipment); sess.update(document); } } if (temp4 != null && temp4.size() != 0) { for (ContragentsInShipment contragent : temp4) { sess.delete(contragent); } } if (temp3 != null && temp3.size() != 0) { for (PositionsInShipment position : temp3) { sess.delete(position); } } sess.update(shipment); sessionFactory.getCurrentSession().delete(shipment); } }
From source file:com.mycompany.CRMFly.hibernateAccess.ShipmentsDAOImpl.java
@Override public List<Payments> getPaymentsForShipment(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("shipments-with-payments"); Shipments shipment = (Shipments) sess.get(Shipments.class, id); return shipment.getPayments(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ShipmentsDAOImpl.java
@Override public List<Documents> getDocumentsForShipment(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("shipments-with-documents"); Shipments shipment = (Shipments) sess.get(Shipments.class, id); return shipment.getDocumentsOnShipment(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ShipmentsDAOImpl.java
@Override public List<ContragentsInShipment> getContragentsForShipment(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("shipments-with-contragents"); Shipments shipment = (Shipments) sess.get(Shipments.class, id); return shipment.getContragents(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ShipmentsDAOImpl.java
@Override public List<PositionsInShipment> getPositionsForShipment(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("shipments-with-productPos"); Shipments shipment = (Shipments) sess.get(Shipments.class, id); return shipment.getProductPositions(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ShipmentsDAOImpl.java
@Override public Clients getClientForPosition(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("shipments-with-clients"); ContragentsInShipment position = (ContragentsInShipment) sess.get(ContragentsInShipment.class, id); return position.getClient(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ShipmentsDAOImpl.java
@Override public Products getProductForPosition(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("shipments-with-products"); PositionsInShipment position = (PositionsInShipment) sess.get(PositionsInShipment.class, id); return position.getProduct(); }