List of usage examples for org.hibernate HibernateException HibernateException
public HibernateException(String message, Throwable cause)
From source file:model.dao.DrinksDAO.java
private void manejaExcepcion(HibernateException he) throws HibernateException { tx.rollback();//ww w . j av a 2 s. c o m throw new HibernateException("Something's Wrong...\n", he); }
From source file:model.dao.ProductsDAO.java
private void manejaExcepcion(HibernateException he) throws HibernateException { tx.rollback();// w ww. j a v a2 s.c o m System.out.println(he); throw new HibernateException("Something's Wrong...\n", he); }
From source file:model.DistritoDAO.java
private void manejarExcepcion(HibernateException e) throws HibernateException { transaction.rollback();/*from ww w .ja v a 2 s. c o m*/ throw new HibernateException("Ocurri un error en la capa de acceso a datos", e); }
From source file:net.mad.ads.base.api.service.helper.StringValuedEnumType.java
License:Open Source License
public void setParameterValues(Properties parameters) { String enumClassName = parameters.getProperty("enumClass"); try {// w ww. j ava 2 s . co m enumClass = (Class<T>) Class.forName(enumClassName).asSubclass(Enum.class) .asSubclass(StringValuedEnum.class); //Validates the class but does not eliminate the cast } catch (ClassNotFoundException cnfe) { throw new HibernateException("Enum class not found", cnfe); } setDefaultValue(parameters.getProperty("defaultValue")); }
From source file:net.servicefixture.sample.util.EnumUserType.java
License:Apache License
public void setParameterValues(Properties parameters) { String javaTypeName = parameters.getProperty("javaType"); try {//w w w . j a v a2 s . c o m javaType = Class.forName(javaTypeName); fromStringMethod = javaType.getMethod("fromString", new Class[] { String.class }); } catch (ClassNotFoundException e) { throw new HibernateException("Class " + javaTypeName + " not found ", e); } catch (SecurityException e) { throw new HibernateException("Can not find method fromString(String) in " + javaTypeName, e); } catch (NoSuchMethodException e) { throw new HibernateException("Can not find method fromString(String) in " + javaTypeName, e); } }
From source file:org.ambraproject.hibernate.GenericEnumUserType.java
License:Apache License
@Override public void setParameterValues(Properties parameters) { String enumClassName = parameters.getProperty("enumClass"); try {/* w w w . ja v a 2s . co m*/ enumClass = Class.forName(enumClassName).asSubclass(Enum.class); } catch (ClassNotFoundException exception) { throw new HibernateException("Enum class not found", exception); } String identifierMethodName = parameters.getProperty("identifierMethod", defaultIdentifierMethodName); try { identifierMethod = enumClass.getMethod(identifierMethodName, new Class[0]); identifierType = identifierMethod.getReturnType(); } catch (Exception exception) { throw new HibernateException("Failed to optain identifier method", exception); } TypeResolver tr = new TypeResolver(); type = (AbstractSingleColumnStandardBasicType) tr.basic(identifierType.getName()); if (type == null) { throw new HibernateException("Unsupported identifier type " + identifierType.getName()); } sqlTypes = new int[] { type.sqlType() }; String valueOfMethodName = parameters.getProperty("valueOfMethod", defaultValueOfMethodName); try { valueOfMethod = enumClass.getMethod(valueOfMethodName, new Class[] { identifierType }); } catch (Exception exception) { throw new HibernateException("Failed to optain valueOf method", exception); } }
From source file:org.ambraproject.hibernate.GenericEnumUserType.java
License:Apache License
@Override public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { Object identifier = type.get(rs, names[0]); try {/*from w w w. j a v a 2 s. c o m*/ for (Object key : enumClass.getEnumConstants()) { Object keyValue = identifierMethod.invoke(key); if (keyValue.equals(identifier)) { return valueOfMethod.invoke(enumClass, identifier); } } log.warn("Found unrecognized enumeration value '{}', for enumeration: {}", identifier, enumClass.toString()); return null; } catch (Exception exception) { throw new HibernateException("Exception while invoking valueOfMethod of enumeration class: ", exception); } }
From source file:org.ambraproject.hibernate.GenericEnumUserType.java
License:Apache License
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { try {/*ww w. j a v a 2s . c o m*/ Object identifier = value != null ? identifierMethod.invoke(value, new Object[0]) : null; st.setObject(index, identifier); } catch (Exception exception) { throw new HibernateException("Exception while invoking identifierMethod of enumeration class: ", exception); } }
From source file:org.ambraproject.hibernate.OTMBlobType.java
License:Apache License
public Object nullSafeGet(ResultSet resultSet, String[] names, Object o) throws HibernateException, SQLException { java.sql.Blob sBlob = resultSet.getBlob(names[0]); if (!resultSet.wasNull()) { try {//www . j av a2 s . c om return newBlob(names[0], sBlob); } catch (Exception ex) { throw new HibernateException(ex.getMessage(), ex); } } return null; }
From source file:org.ambraproject.hibernate.URIType.java
License:Apache License
public boolean equals(java.lang.Object o, java.lang.Object o1) throws org.hibernate.HibernateException { if (o == null) { if (o1 == null) { return true; } else {//from w w w . j av a 2 s . c om return false; } } URI u; URI u1; if (o instanceof String) { try { u = new URI((String) o); } catch (URISyntaxException ex) { throw new HibernateException(ex.getMessage(), ex); } } else { u = (URI) o; } if (o1 instanceof String) { try { u1 = new URI((String) o1); } catch (URISyntaxException ex) { throw new HibernateException(ex.getMessage(), ex); } } else { u1 = (URI) o1; } return ((URI) u).equals(u1); }