List of usage examples for org.hibernate Session enableFetchProfile
void enableFetchProfile(String name) throws UnknownProfileException;
From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java
public void deleteManufacturerConnection(Products product, Organisations organisation) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("products-with-manufacturers"); product = (Products) sess.load(Products.class, product.getId()); product.getManufacturers().remove(organisation); sess.update(organisation);/*www. j av a2 s .co m*/ organisation = (Organisations) sess.load(Organisations.class, organisation.getId()); organisation.getProducts().remove(product); sess.update(organisation); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java
@Override public void removeProduct(Products product) { if (null != product) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); product = (Products) sess.get(Products.class, product.getId()); List<Organisations> temp = product.getManufacturers(); if (temp != null && temp.size() != 0) { sess.enableFetchProfile("products-with-manufacturers"); temp = organisationsDAO.getFromProxy(temp); for (Organisations organisation : temp) { organisation.getProducts().remove(product); sess.update(organisation); }//www . java 2s . c o m } sess.update(product); sessionFactory.getCurrentSession().delete(product); } }
From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java
@Override public List<PositionsInContract> getContractPositionsForProduct(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("products-with-positionsCont"); Products product = (Products) sess.get(Products.class, id); return product.getPositionsInContract(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java
@Override public List<PositionsInShipment> getShipmentPositionsForProduct(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("products-with-positionsShip"); Products product = (Products) sess.get(Products.class, id); return product.getPositionsInShipment(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java
@Override public Contracts getContractForPosition(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("products-with-contracts"); PositionsInContract position = (PositionsInContract) sess.get(PositionsInContract.class, id); return position.getContract(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java
@Override public Shipments getShipmentForPosition(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("products-with-shipments"); PositionsInShipment position = (PositionsInShipment) sess.get(PositionsInShipment.class, id); return position.getShipment(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java
@Override public List<Organisations> getManufacturersOfProduct(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("products-with-manufacturers"); Products product = (Products) sess.get(Products.class, id); return product.getManufacturers(); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java
public List<Contracts> getContractsForProduct(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("products-with-positionsCont"); sess.enableFetchProfile("products-with-contracts"); Products product = (Products) sess.get(Products.class, id); List<Contracts> returnList = new ArrayList<Contracts>(); List<PositionsInContract> contrList = product.getPositionsInContract(); for (PositionsInContract con : contrList) { returnList.add(con.getContract()); }//from w ww .jav a 2 s . co m return returnList; }
From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java
public List<Shipments> getShipmentsForProduct(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("products-with-positionsShip"); sess.enableFetchProfile("products-with-shipments"); Products product = (Products) sess.get(Products.class, id); List<Shipments> returnList = new ArrayList<Shipments>(); List<PositionsInShipment> shipList = product.getPositionsInShipment(); for (PositionsInShipment ship : shipList) { returnList.add(ship.getShipment()); }/*from w w w. j av a 2 s .c o m*/ return returnList; }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
@Override public void addProject(Projects project) { sessionFactory.getCurrentSession().save(project); List<Daily> temp = project.getTasksConnectedWithProject(); List<Events> temp2 = project.getEventsConnectedWithProjects(); List<Employees> temp3 = project.getParticipants(); List<ParticipantsInProject> temp4 = project.getOrganisationsInProject(); if (temp != null && temp.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-tasks"); temp = dailyDAO.getFromProxy(temp); for (Daily task : temp) { task.setProject(project);// w w w .jav a 2s . c om dailyDAO.changeTask(task); } } if (temp2 != null && temp2.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-events"); temp2 = eventsDAO.getFromProxy(temp2); for (Events event : temp2) { event.getConnectedProjects().add(project); eventsDAO.changeEvent(event); } } if (temp3 != null && temp3.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-employees"); temp3 = employeesDAO.getFromProxy(temp3); for (Employees employee : temp3) { employee.getResponsibleForProjects().add(project); employeesDAO.changeEmployee(employee); } } if (temp4 != null && temp4.size() != 0) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-organisations"); for (ParticipantsInProject organisation : temp4) { organisation.setProject(project); sessionFactory.getCurrentSession().save(organisation); } } }