List of usage examples for org.hibernate Session enableFetchProfile
void enableFetchProfile(String name) throws UnknownProfileException;
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
public void addTaskConnection(Projects project, Daily task) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-tasks"); project = (Projects) sess.load(Projects.class, project.getId()); project.getTasksConnectedWithProject().add(task); sess.update(project);/*from w w w. ja v a2s. com*/ task = (Daily) sess.load(Daily.class, task.getId()); task.setProject(project); sess.update(task); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
public void addEventConnection(Projects project, Events event) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-events"); project = (Projects) sess.load(Projects.class, project.getId()); project.getEventsConnectedWithProjects().add(event); sess.update(project);/*from w ww. j a v a2 s . c o m*/ event = (Events) sess.load(Events.class, event.getId()); event.getConnectedProjects().add(project); sess.update(event); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
public void addEmployeeConnection(Projects project, Employees employee) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-employees"); project = (Projects) sess.load(Projects.class, project.getId()); project.getParticipants().add(employee); sess.update(project);//from w w w .ja v a 2 s . co m employee = (Employees) sess.load(Employees.class, employee.getId()); employee.getParticipate().add(project); sess.update(employee); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
public void addOrganisationConnection(Projects project, ParticipantsInProject participant) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-orgs"); sess.enableFetchProfile("orgs-with-projects"); project = (Projects) sess.load(Projects.class, project.getId()); project.getOrganisationsInProject().add(participant); sess.update(project);/*from ww w. j a va 2 s. c o m*/ sess.save(participant); participant = (ParticipantsInProject) sess.load(ParticipantsInProject.class, participant.getId()); Organisations org = participant.getOrganisation(); org.getParticipateInProjects().add(participant); sess.update(org); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
public void deleteTaskConnection(Projects project, Daily task) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-tasks"); project = (Projects) sess.load(Projects.class, project.getId()); project.getTasksConnectedWithProject().remove(task); sess.update(project);/*from w ww . ja va 2s . co m*/ task = (Daily) sess.load(Daily.class, task.getId()); task.setProject(null); sess.update(task); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
public void deleteEventConnection(Projects project, Events event) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-events"); project = (Projects) sess.load(Projects.class, project.getId()); project.getEventsConnectedWithProjects().remove(event); sess.update(project);//ww w . ja va 2 s . c o m event = (Events) sess.load(Events.class, event.getId()); event.getConnectedProjects().remove(project); sess.update(event); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
public void deleteEmployeeConnection(Projects project, Employees employee) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-employees"); project = (Projects) sess.load(Projects.class, project.getId()); project.getParticipants().remove(employee); sess.update(project);//from ww w . j av a 2 s . co m employee = (Employees) sess.load(Employees.class, employee.getId()); employee.getParticipate().remove(project); sess.update(employee); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
public void deleteOrganisationConnection(Projects project, ParticipantsInProject participant) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-orgs"); sess.enableFetchProfile("orgs-with-projects"); project = (Projects) sess.load(Projects.class, project.getId()); project.getOrganisationsInProject().remove(participant); sess.update(project);//from w w w . j a v a2 s.c o m participant = (ParticipantsInProject) sess.load(ParticipantsInProject.class, participant.getId()); Organisations org = participant.getOrganisation(); org.getParticipateInProjects().remove(participant); sess.update(org); sess.delete(participant); }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
@Override public void removeProject(Projects project) { if (null != project) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); project = (Projects) sess.get(Projects.class, project.getId()); 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) { sess.enableFetchProfile("projects-with-tasks"); temp = dailyDAO.getFromProxy(temp); for (Daily task : temp) { task.setProject(null);/* w w w. ja v a 2 s . c o m*/ sess.update(task); } } if (temp2 != null && temp2.size() != 0) { sess.enableFetchProfile("projects-with-events"); temp2 = eventsDAO.getFromProxy(temp2); for (Events event : temp2) { event.getConnectedProjects().remove(project); sess.update(event); } } if (temp3 != null && temp3.size() != 0) { sess.enableFetchProfile("projects-with-employees"); temp3 = employeesDAO.getFromProxy(temp3); for (Employees employee : temp3) { employee.getParticipate().remove(project); sess.update(employee); } } if (temp4 != null && temp4.size() != 0) { sess.enableFetchProfile("projects-with-organisations"); for (ParticipantsInProject organisation : temp4) { sess.delete(organisation); } } sess.update(project); sessionFactory.getCurrentSession().delete(project); } }
From source file:com.mycompany.CRMFly.hibernateAccess.ProjectsDAOImpl.java
@Override public List<Daily> getConnectedTasks(Long id) { org.hibernate.Session sess = sessionFactory.getCurrentSession(); sess.enableFetchProfile("projects-with-tasks"); Projects project = (Projects) sess.get(Projects.class, id); return project.getTasksConnectedWithProject(); }