Example usage for org.hibernate HibernateException HibernateException

List of usage examples for org.hibernate HibernateException HibernateException

Introduction

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

Prototype

public HibernateException(Throwable cause) 

Source Link

Document

Constructs a HibernateException using the given message and underlying cause.

Usage

From source file:hibernate.dao.TbCareersDao.java

public TbCareers SelectRow(long IdRow) throws HibernateException {
    TbCareers objTbCareer = null;/* w  w  w.j ava 2 s.co  m*/
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        objTbCareer = (TbCareers) session.get(TbCareers.class, IdRow);
    } catch (HibernateException ex) {
        throw new HibernateException("Error in access to data...  \b ->" + ex);
    } finally {
        session.close();
    }
    return objTbCareer;
}

From source file:hibernate.dao.TbCareersDao.java

public List<TbCareers> SelectRows() throws HibernateException {
    List<TbCareers> listTbCareers = null;
    try {/*from ww w . j a va2  s . c  o  m*/
        session = HibernateUtil.getSessionFactory().openSession();
        listTbCareers = session.createSQLQuery("SELECT * FROM Tb_Careers").addEntity(TbCareers.class).list();
    } catch (HibernateException ex) {
        throw new HibernateException("Error in access to data...  \b ->" + ex);
    } finally {
        session.close();
    }
    return listTbCareers;
}

From source file:hibernate.dao.TbCareersDao.java

public List<Object[]> SelectStudentsAndCareerRows(String conditions) throws HibernateException {
    SQLQuery SqlQuery;//from   w  ww.j av  a  2 s .  c  om
    List<Object[]> list = null;
    String query = "SELECT * FROM Tb_Careers, Tb_Students WHERE Tb_Students.fl_fk_career=Tb_Careers.fl_pk_career";
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        SqlQuery = session.createSQLQuery(query);
        SqlQuery.addEntity(TbCareers.class);
        SqlQuery.addEntity(TbStudents.class);
        list = SqlQuery.list();
    } catch (HibernateException ex) {
        throw new HibernateException("Error in access to data...  \b ->" + ex);
    } finally {
        session.close();
    }
    return list;
}

From source file:io.github.jonestimd.hibernate.EnumUserType.java

License:Open Source License

public void setParameterValues(Properties parameters) {
    String className = parameters.getProperty("enumClass");
    try {// ww  w  .ja  va 2s  .  co m
        enumClass = Class.forName(className).asSubclass(Enum.class);
    } catch (ClassNotFoundException ex) {
        throw new HibernateException("Enum class not found: " + className);
    }
}

From source file:it.doqui.index.ecmengine.business.personalization.hibernate.RoutingLocalDataSourceConnectionProvider.java

License:Open Source License

/**
 * Configura il provider./*from   ww  w.ja  va 2 s. co  m*/
 * 
 * <strong>NB:</strong> le propriet&agrave; specificate in input vengono ignorate da questa implementazione.
 * 
 * @param props Un oggetto {@code Properties} contenente i parametri di configurazione (ignorate).
 * 
 * @throws HibernateException Se si verifica un errore durante la configurazione di hibernate.
 */
public void configure(Properties props) throws HibernateException {
    logger.debug("[RoutingLocalDataSourceConnectionProvider::configure] BEGIN");

    try {
        this.dataSource = RoutingLocalSessionFactoryBean.getConfigTimeDataSource();
        if (this.dataSource == null) {
            throw new HibernateException("No local DataSource found for configuration - "
                    + "dataSource property must be set on RoutingLocalSessionFactoryBean");
        }
    } finally {
        logger.debug("[RoutingLocalDataSourceConnectionProvider::configure] END");
    }
}

From source file:kr.debop4j.data.hibernate.unitofwork.UnitOfWorks.java

License:Apache License

/**  ? {@link IUnitOfWork}? ? ({@link UnitOfWorkAdapter} . */
public static synchronized IUnitOfWork getCurrent() {
    if (!isStarted())
        throw new HibernateException(UNIT_OF_WORK_NOT_STARTED);

    if (globalNonThreadSafeUnitOfWork != null)
        return globalNonThreadSafeUnitOfWork;

    return Local.get(IUnitOfWork.CURRENT_UNIT_OF_WORK_KEY, IUnitOfWork.class);
}

From source file:kr.debop4j.data.hibernate.usertype.AbstractJsonTextUserType.java

License:Apache License

/**
 * Json ? ? ? ? .//from   w w w.  j a  v a 2  s .co m
 *
 * @param jto Json ?
 * @return ? ? ?
 * @throws HibernateException
 */
@SuppressWarnings("unchecked")
public Object deserialize(final JsonTextObject jto) throws HibernateException {

    if (jto == null || jto == JsonTextObject.Empty)
        return null;

    if (isTraceEnabled)
        log.trace("JsonTextObject ? . jto=[{}]", jto);

    try {
        Class clazz = Class.forName(jto.getClassName());
        return getJsonSerializer().deserializeFromText(jto.getJsonText(), clazz);
    } catch (ClassNotFoundException e) {
        return new HibernateException(e);
    }
}

From source file:kr.debop4j.data.hibernate.usertype.AbstractJsonTextUserType.java

License:Apache License

@Override
public Object getPropertyValue(Object component, int property) throws HibernateException {
    if (component == null)
        return null;

    JsonTextObject jto = asJsonTextObject(component);
    if (property == 0)
        return jto.getClassName();
    else if (property == 1)
        return jto.getJsonText();
    else/*from w w w .j  a  va2  s  . c  o m*/
        throw new HibernateException(
                "? ? ??  . 0, 1 . property="
                        + property);
}

From source file:kr.debop4j.data.hibernate.usertype.AbstractJsonTextUserType.java

License:Apache License

@Override
public void setPropertyValue(Object component, int property, Object value) throws HibernateException {
    Guard.shouldNotBeNull(component, "compnent");

    JsonTextObject jto = asJsonTextObject(component);
    if (property == 0)
        jto.setClassName((String) value);
    else if (property == 1)
        jto.setJsonText((String) value);
    else/*from  w  w  w.  j  a  v a 2  s.  c  o  m*/
        throw new HibernateException(
                "? ? ??  . 0, 1 . property="
                        + property);
}

From source file:kr.debop4j.data.hibernate.usertype.WeekOfYearUserType.java

License:Apache License

@Override
public Object getPropertyValue(final Object component, final int property) throws HibernateException {
    Guard.shouldNotBeNull(component, "component");
    YearWeek yw = asYearWeek(component);

    if (property == 0)
        return yw.getYear();
    else if (property == 1)
        return yw.getWeek();
    else/* w  w w. j  av  a 2  s .c om*/
        throw new HibernateException(
                "property index  . 0, 1 ?  . property="
                        + property);
}