Example usage for org.hibernate Hibernate initialize

List of usage examples for org.hibernate Hibernate initialize

Introduction

In this page you can find the example usage for org.hibernate Hibernate initialize.

Prototype

public static void initialize(Object proxy) throws HibernateException 

Source Link

Document

Force initialization of a proxy or persistent collection.

Usage

From source file:com.ikon.dao.AutomationDAO.java

License:Open Source License

/**
 * Force initialization of a proxy/*from  w w w . ja  v a  2  s  . c om*/
 */
private void initialize(AutomationRule aRule) {
    if (aRule != null) {
        Hibernate.initialize(aRule);
        initializeActions(aRule.getActions());
        initializeValidations(aRule.getValidations());
    }
}

From source file:com.ikon.dao.AutomationDAO.java

License:Open Source License

/**
 * Force initialization of a proxy// www. ja  va2s. c  o m
 */
private void initialize(AutomationValidation aValidation) {
    if (aValidation != null) {
        Hibernate.initialize(aValidation);
        Hibernate.initialize(aValidation.getParams());
    }
}

From source file:com.ikon.dao.AutomationDAO.java

License:Open Source License

/**
 * Force initialization of a proxy//from  w w w.  ja  v a  2s .  co  m
 */
private void initialize(AutomationAction aAction) {
    if (aAction != null) {
        Hibernate.initialize(aAction);
        Hibernate.initialize(aAction.getParams());
    }
}

From source file:com.ikon.dao.ConfigDAO.java

License:Open Source License

/**
 * Find by pk//ww w  .  j av a 2  s. c  o  m
 */
public static Config findByPk(String key) throws DatabaseException {
    log.debug("findByPk({})", key);
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        Config ret = (Config) session.load(Config.class, key);
        Hibernate.initialize(ret);
        HibernateUtil.commit(tx);
        log.debug("findByPk: {}", ret);
        return ret;
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.ikon.dao.GenericDAO.java

License:Open Source License

/**
 * Find by primary key/*from w  ww .  j a  v a  2s. co m*/
 */
@SuppressWarnings("unchecked")
public T findByPk(ID id) throws DatabaseException {
    log.debug("findByPk({})", id);
    Session session = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        T ret = (T) session.load(persistentClass, id);
        Hibernate.initialize(ret);
        log.debug("findByPk: {}", ret);
        return ret;
    } catch (HibernateException e) {
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.ikon.dao.LanguageDAO.java

License:Open Source License

/**
 * Find translations by pk/*from  w w  w . j a  v  a2 s .c o  m*/
 */
public static Language findByPk(String id) throws DatabaseException {
    log.debug("findByPk({})", id);
    Session session = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        Language ret = (Language) session.load(Language.class, id);
        Hibernate.initialize(ret);
        log.debug("findByPk: {}", ret);
        return ret;
    } catch (HibernateException e) {
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.ikon.dao.MimeTypeDAO.java

License:Open Source License

/**
 * Find by pk/*from  w  ww .ja va 2 s  . co  m*/
 */
public static MimeType findByPk(long mtId) throws DatabaseException {
    log.debug("findByPk({})", mtId);
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        MimeType ret = (MimeType) session.load(MimeType.class, mtId);
        Hibernate.initialize(ret);
        HibernateUtil.commit(tx);
        log.debug("findByPk: {}", ret);
        return ret;
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.ikon.dao.NodeBaseDAO.java

License:Open Source License

/**
 * Get user permissions// ww  w . ja  va 2  s  .com
 */
public Map<String, Integer> getUserPermissions(String uuid) throws PathNotFoundException, DatabaseException {
    log.debug("getUserPermissions({})", uuid);
    Map<String, Integer> ret = new HashMap<String, Integer>();
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();

        // Security Check
        NodeBase node = (NodeBase) session.load(NodeBase.class, uuid);
        SecurityHelper.checkRead(node);

        if (node != null) {
            Hibernate.initialize(ret = node.getUserPermissions());
        }

        HibernateUtil.commit(tx);
        log.debug("getUserPermissions: {}", ret);
        return ret;
    } catch (PathNotFoundException e) {
        HibernateUtil.rollback(tx);
        throw e;
    } catch (DatabaseException e) {
        HibernateUtil.rollback(tx);
        throw e;
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.ikon.dao.NodeBaseDAO.java

License:Open Source License

/**
 * Get role permissions/*www  .ja va  2 s  .c  o  m*/
 */
public Map<String, Integer> getRolePermissions(String uuid) throws PathNotFoundException, DatabaseException {
    log.debug("getRolePermissions({})", uuid);
    Map<String, Integer> ret = new HashMap<String, Integer>();
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();

        // Security Check
        NodeBase node = (NodeBase) session.load(NodeBase.class, uuid);
        SecurityHelper.checkRead(node);

        if (node != null) {
            Hibernate.initialize(ret = node.getRolePermissions());
        }

        HibernateUtil.commit(tx);
        log.debug("getRolePermissions: {}", ret);
        return ret;
    } catch (PathNotFoundException e) {
        HibernateUtil.rollback(tx);
        throw e;
    } catch (DatabaseException e) {
        HibernateUtil.rollback(tx);
        throw e;
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.ikon.dao.NodeBaseDAO.java

License:Open Source License

/**
 * Get node subscriptors//from w w w.j av a 2 s  .  co  m
 */
public Set<String> getSubscriptors(String uuid) throws PathNotFoundException, DatabaseException {
    log.debug("getSubscriptors({})", uuid);
    Session session = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();

        // Security Check
        NodeBase node = (NodeBase) session.load(NodeBase.class, uuid);
        SecurityHelper.checkRead(node);

        Set<String> subscriptors = node.getSubscriptors();
        Hibernate.initialize(subscriptors);
        log.debug("getSubscriptors: {}", subscriptors);
        return subscriptors;
    } catch (PathNotFoundException e) {
        throw e;
    } catch (HibernateException e) {
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}