Example usage for org.hibernate Session load

List of usage examples for org.hibernate Session load

Introduction

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

Prototype

void load(Object object, Serializable id);

Source Link

Document

Read the persistent state associated with the given identifier into the given transient instance.

Usage

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

License:Open Source License

/**
 * Find by pk//from   www.j a v 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.CronTabDAO.java

License:Open Source License

/**
 * Delete//from   www . ja  va 2 s  .  co m
 */
public static void delete(long ctId) throws DatabaseException {
    log.debug("delete({})", ctId);
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        CronTab ct = (CronTab) session.load(CronTab.class, ctId);
        session.delete(ct);
        HibernateUtil.commit(tx);
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }

    log.debug("delete: void");
}

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

License:Open Source License

/**
 * Set begin time/*from   www . jav a2  s  .  c  o m*/
 */
public static void setLastBegin(long ctId) throws DatabaseException {
    log.debug("setLastBegin({})", ctId);
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        CronTab ct = (CronTab) session.load(CronTab.class, ctId);
        ct.setLastBegin(Calendar.getInstance());
        session.update(ct);
        HibernateUtil.commit(tx);
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }

    log.debug("setLastBegin: void");
}

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

License:Open Source License

/**
 * Set end time/*  ww w  .ja va 2 s  .  c  o m*/
 */
public static void setLastEnd(long ctId) throws DatabaseException {
    log.debug("setLastEnd({})", ctId);
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        CronTab ct = (CronTab) session.load(CronTab.class, ctId);
        ct.setLastEnd(Calendar.getInstance());
        session.update(ct);
        HibernateUtil.commit(tx);
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }

    log.debug("setLastEnd: void");
}

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

License:Open Source License

/**
 * Delete dashboard stats//w  ww. ja  v a 2  s  . c om
 */
public void delete(int dsId) throws DatabaseException {
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        Dashboard ds = (Dashboard) session.load(Dashboard.class, dsId);
        session.delete(ds);
        HibernateUtil.commit(tx);
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

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

License:Open Source License

/**
 * Delete//from w w w . ja v  a  2  s .c  o  m
 */
public static void deleteValue(long dmvId) throws DatabaseException {
    log.debug("deleteValue({})", dmvId);
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        DatabaseMetadataValue dmv = (DatabaseMetadataValue) session.load(DatabaseMetadataValue.class, dmvId);
        session.delete(dmv);
        HibernateUtil.commit(tx);
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }

    log.debug("deleteValue: void");
}

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

License:Open Source License

/**
 * Delete/*from  ww w.  j a  v a 2 s .  co  m*/
 */
public static void deleteType(long dmtId) throws DatabaseException {
    log.debug("deleteType({})", dmtId);
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        DatabaseMetadataType emt = (DatabaseMetadataType) session.load(DatabaseMetadataType.class, dmtId);
        session.delete(emt);
        HibernateUtil.commit(tx);
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }

    log.debug("deleteType: void");
}

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

License:Open Source License

/**
 * Delete/*from  w  w w  .jav  a2 s. c  o m*/
 */
@SuppressWarnings("unchecked")
public void delete(ID id) throws DatabaseException {
    log.debug("delete({})", id);
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        T t = (T) session.load(persistentClass, id);
        session.delete(t);
        HibernateUtil.commit(tx);
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }

    log.debug("delete: void");
}

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

License:Open Source License

/**
 * Find by primary key//from  www .  jav a  2  s . c  o 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 www. j a va 2s . 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);
    }
}