List of usage examples for org.hibernate HibernateException HibernateException
public HibernateException(Throwable cause)
From source file:com.moss.telephone.hibernate.MultiColumnPhoneNumberUserType.java
License:Open Source License
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { String countryCodeString = rs.getString(names[0]); String areaCodeString = rs.getString(names[1]); String subscriberNumberString = rs.getString(names[2]); try {//from ww w .j ava2 s.c o m return new PhoneNumber(countryCodeString, areaCodeString, subscriberNumberString); } catch (TelephoneNumberFormatException e) { throw new HibernateException(e); } }
From source file:com.moss.telephone.hibernate.PhoneNumberUserType.java
License:Open Source License
public Object assemble(Serializable cached, Object owner) throws HibernateException { try {/* ww w .j av a 2 s . com*/ return new PhoneNumber(cached.toString()); } catch (TelephoneNumberFormatException e) { throw new HibernateException(e); } }
From source file:com.moss.telephone.hibernate.PhoneNumberUserType.java
License:Open Source License
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { try {// ww w . j ava 2 s .com String text = rs.getString(names[0]); if (text == null) return null; else return new PhoneNumber(text); } catch (TelephoneNumberFormatException e) { throw new HibernateException(e); } }
From source file:com.moss.telephone.hibernate.SubscriberNumberUserType.java
License:Open Source License
public Object deepCopy(Object arg0) throws HibernateException { try {/*from ww w. j a v a 2s . c o m*/ if (arg0 == null) return null; return new SubscriberNumber(arg0.toString()); } catch (TelephoneNumberFormatException e) { throw new HibernateException(e); } }
From source file:com.moss.telephone.hibernate.TelephoneNumberSegmentUserType.java
License:Open Source License
public Object nullSafeGet(ResultSet rs, String[] columns, Object arg2) throws HibernateException, SQLException { String value = rs.getString(columns[0]); if (value == null) return null; try {/* w ww . j a va 2s . c o m*/ return fromString(value); } catch (Exception e) { throw new HibernateException(e); } }
From source file:com.moss.telephone.hibernate.TelephoneNumberSegmentUserType.java
License:Open Source License
public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException { try {//from ww w .j a va 2 s.c om if (value == null) { statement.setNull(index, Types.VARCHAR); } else { statement.setString(index, toString(value)); } } catch (SQLException e) { throw e; } catch (Exception e) { throw new HibernateException(e); } }
From source file:com.muslim.family.dao.impl.LoginDAOImpl.java
@Override public String checkShaikhCredentialDao(LoginCredentials login) { Query query = sessionFactory.getCurrentSession() .createQuery("from Shaikh_tbl shk where shk.email= :email and shk.password= :pass"); query.setString("email", login.getEmail()); query.setString("pass", login.getPassword()); Shaikh_tbl shaikh = (Shaikh_tbl) query.list().get(0); if (shaikh == null) throw new HibernateException( "Login Credentials are incorect.. Please check your username and password"); return shaikh.getEmail(); }
From source file:com.namphibian.pgdilato.PostgresqlUserDefinedArrayType.java
@Override public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { Connection connection = session.connection(); List<Object> list = (List<Object>) value; Object[] array = list == null ? null : list.toArray(); try {/*w ww. ja v a 2s.c om*/ statement.setArray(index, connection.createArrayOf(this.pgsqlType, array)); } catch (Exception e) { throw new HibernateException("Error during persisting of data: " + e.getLocalizedMessage()); } }
From source file:com.netradius.hibernate.support.EncryptedUserType.java
License:Apache License
/** * {@inheritDoc}/*ww w.j a v a 2 s. co m*/ */ public Object nullSafeGet(final ResultSet rs, final String[] names, final SessionImplementor impl, final Object owner) throws HibernateException, SQLException { try { final byte[] data = rs.getBytes(names[0]); return rs.wasNull() ? null : doFinal(getCipher(Cipher.DECRYPT_MODE), data); } catch (GeneralSecurityException x) { throw new HibernateException("Failed to retrieve encrypted value: " + x.getMessage()); } }
From source file:com.netradius.hibernate.support.EncryptedUserType.java
License:Apache License
/** * Helper method to create a cipher./*ww w. j av a2 s. c om*/ * * @param mode the mode for the cipher (eg. Cipher.DECRYPT_MODE or Cipher.ENCRYPT_MODE) * @param algorithm the cryptographic algorithm (eg. AES) * @param transformation the name of the transformation (eg. AES/CBC/PKCS5Padding) * @param provider the name of the provider (eg. JCE) * @param key the encryption key * @param iv the initialization vector or null * @return the created cipher * @throws NoSuchAlgorithmException if the cryptographic algorithm cannot be found * @throws NoSuchPaddingException the the padding algorithm cannot be found * @throws InvalidKeyException if the key is invalid * @throws InvalidAlgorithmParameterException if the initialization vector is invalid */ public static Cipher getCipher(final int mode, final String algorithm, final String transformation, final String provider, final byte[] key, final byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { final Provider p = Security.getProvider(provider); if (p == null) { throw new HibernateException("Failed to find provider " + provider); } IvParameterSpec i = new IvParameterSpec(iv); Key k = new SecretKeySpec(key, algorithm); return getCipher(mode, transformation, p, k, i); }