Example usage for org.hibernate Session enableFetchProfile

List of usage examples for org.hibernate Session enableFetchProfile

Introduction

In this page you can find the example usage for org.hibernate Session enableFetchProfile.

Prototype

void enableFetchProfile(String name) throws UnknownProfileException;

Source Link

Document

Enable a particular fetch profile on this session.

Usage

From source file:com.mycompany.CRMFly.hibernateAccess.ProcessDAOImpl.java

@Override
public List<Payments> getProcessPayments(Long id) {
    org.hibernate.Session sess = sessionFactory.getCurrentSession();
    sess.enableFetchProfile("process-with-payments");
    SalesProcess process = (SalesProcess) sess.get(SalesProcess.class, id);
    return process.getPayments();
}

From source file:com.mycompany.CRMFly.hibernateAccess.ProcessDAOImpl.java

@Override
public List<Shipments> getProcessShipments(Long id) {
    org.hibernate.Session sess = sessionFactory.getCurrentSession();
    sess.enableFetchProfile("process-with-shipments");
    SalesProcess process = (SalesProcess) sess.get(SalesProcess.class, id);
    return process.getShipments();
}

From source file:com.mycompany.CRMFly.hibernateAccess.ProcessDAOImpl.java

@Override
public void addContractConnection(SalesProcess process, Contracts contract) {
    org.hibernate.Session sess = sessionFactory.getCurrentSession();
    sess.enableFetchProfile("process-with-contract");
    contract.setProcess(process);/*  www.  j  a v  a 2s  . com*/
    sess.update(contract);
    process.setContract(contract);
    sess.update(process);
}

From source file:com.mycompany.CRMFly.hibernateAccess.ProcessDAOImpl.java

@Override
public void addRequestConnection(SalesProcess process, Requests request) {
    org.hibernate.Session sess = sessionFactory.getCurrentSession();
    sess.enableFetchProfile("process-with-request");
    request.setProcess(process);/*from ww  w .  j a v a 2s  . c om*/
    sess.update(request);
    process.setOffer(request);
    sess.update(process);
}

From source file:com.mycompany.CRMFly.hibernateAccess.ProcessDAOImpl.java

@Override
public void addPaymentConnection(SalesProcess process, Payments payment) {
    org.hibernate.Session sess = sessionFactory.getCurrentSession();
    sess.enableFetchProfile("process-with-contract");
    payment.setContractOnPayment(process.getContract());
    sess.update(payment);// w  w  w .j a  va 2  s .  c  o m
    sess.enableFetchProfile("process-with-payments");
    process = (SalesProcess) sess.get(SalesProcess.class, process.getId());
    process.getPayments().add(payment);
    sess.update(process);
}

From source file:com.mycompany.CRMFly.hibernateAccess.ProcessDAOImpl.java

@Override
public void addShipmentConnection(SalesProcess process, Shipments shipment) {
    org.hibernate.Session sess = sessionFactory.getCurrentSession();
    sess.enableFetchProfile("process-with-contract");
    shipment.setContract(process.getContract());
    sess.update(shipment);/*w ww .  j  a v a2 s.  c o m*/
    sess.enableFetchProfile("process-with-shipments");
    process = (SalesProcess) sess.get(SalesProcess.class, process.getId());
    process.getShipments().add(shipment);
    sess.update(process);
}

From source file:com.mycompany.CRMFly.hibernateAccess.ProcessDAOImpl.java

@Override
public Requests getProcessRequest(Long id) {
    org.hibernate.Session sess = sessionFactory.getCurrentSession();
    sess.enableFetchProfile("process-with-request");
    SalesProcess process = (SalesProcess) sess.get(SalesProcess.class, id);
    return process.getOffer();
}

From source file:com.mycompany.CRMFly.hibernateAccess.ProcessDAOImpl.java

@Override
public Contracts getProcessContract(Long id) {
    org.hibernate.Session sess = sessionFactory.getCurrentSession();
    sess.enableFetchProfile("process-with-contract");
    SalesProcess process = (SalesProcess) sess.get(SalesProcess.class, id);
    return process.getContract();
}

From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java

@Override
public void addProduct(Products product) {
    sessionFactory.getCurrentSession().save(product);
    List<Organisations> temp = product.getManufacturers();
    if (temp != null && temp.size() != 0) {
        org.hibernate.Session sess = sessionFactory.getCurrentSession();
        sess.enableFetchProfile("products-with-manufacturers");
        temp = organisationsDAO.getFromProxy(temp);
        for (Organisations organisation : temp) {
            organisation.getProducts().add(product);
            organisationsDAO.changeOrganisation(organisation);
        }//from w ww . jav  a2 s.co  m

    }
}

From source file:com.mycompany.CRMFly.hibernateAccess.ProductsDAOImpl.java

public void addManufacturerConnection(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().add(organisation);
    sess.update(organisation);//w  w w .  j  ava  2 s  .co m
    organisation = (Organisations) sess.load(Organisations.class, organisation.getId());
    organisation.getProducts().add(product);
    sess.update(organisation);
}