@Override public int[] sqlTypes() { return new int[] {StringType.INSTANCE.sqlType()}; }
public void nullSafeSet( final PreparedStatement st, final Object value, final int index, final SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( value == null ) { st.setNull( index, StringType.INSTANCE.sqlType() ); st.setNull( index + 1, IntegerType.INSTANCE.sqlType() ); } else { final Component comp = (Component) value; st.setString( index, comp.getProp1() ); st.setInt( index + 1, comp.getProp2() ); } }
@Override public int[] sqlTypes() { return new int[]{StringType.INSTANCE.sqlType()}; }
@Override public int[] sqlTypes() { return new int[]{ delegateType.sqlType() }; }
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { st.setNull(index, StringType.INSTANCE.sqlType()); st.setNull(index + 1, StringType.INSTANCE.sqlType()); } else { st.setString(index, value.getClass().getName()); st.setString(index + 1, value.toString()); } }
@Override public void nullSafeSet(final PreparedStatement st, final Object value, final int index, final SessionImplementor session) throws HibernateException { try { if (value == null) { st.setNull(index, type.sqlType()); } else { final String identifier = (String) identifierMethod.invoke(value, new Object[0]); type.set(st, identifier, index, session); } } catch (final Exception e) { final StringBuilder stb = new StringBuilder("Exception while invoking identifierMethod '"); stb.append(valueOfMethod.getName()); stb.append("' of enumeration class '"); stb.append(enumClass); stb.append('\''); throw new HibernateException(stb.toString(), e); } }
@Override public void nullSafeSet(final PreparedStatement st, final Object value, final int index, final SessionImplementor session) throws HibernateException { try { if (value == null) { st.setNull(index, type.sqlType()); } else { final String identifier = (String) identifierMethod.invoke(value, new Object[0]); type.set(st, identifier, index, session); } } catch (final Exception e) { final StringBuilder stb = new StringBuilder("Exception while invoking identifierMethod '"); stb.append(valueOfMethod.getName()); stb.append("' of enumeration class '"); stb.append(enumClass); stb.append('\''); throw new HibernateException(stb.toString(), e); } }
@Override public void setParameterValues(final Properties parameters) { final String enumClassName = parameters.getProperty("enumClass"); try { enumClass = Class.forName(enumClassName).asSubclass(Enum.class); } catch (final ClassNotFoundException cfne) { final String message = "Enum class not found"; throw new HibernateException(message, cfne); } final String identifierMethodName = parameters.getProperty("identifierMethod", DEFAULT_IDENTIFIER_METHOD_NAME); try { identifierMethod = enumClass.getMethod(identifierMethodName, new Class[0]); identifierType = identifierMethod.getReturnType(); } catch (final Exception e) { final String message = "Failed to obtain identifier method"; throw new HibernateException(message, e); } sqlTypes = new int[] { type.sqlType() }; final String valueOfMethodName = parameters.getProperty("valueOfMethod", DEFAULT_VALUE_OF_METHOD_NAME); try { valueOfMethod = enumClass.getMethod(valueOfMethodName, new Class[] { identifierType }); } catch (final Exception e) { final String message = "Failed to obtain valueOf method"; throw new HibernateException(message, e); } }
/** * {@inheritDoc} */ @Override public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if (value == null) { st.setNull(index, StandardBasicTypes.STRING.sqlType()); st.setNull(index + 1, StandardBasicTypes.BIG_DECIMAL.sqlType()); } else { Piece piece = (Piece) value; String unitType = piece.getUnitType().toString(); st.setString(index, unitType); st.setBigDecimal(index + 1, piece.getMagnitude()); } }
@Override public void setParameterValues(final Properties parameters) { final String enumClassName = parameters.getProperty("enumClass"); try { enumClass = Class.forName(enumClassName).asSubclass(Enum.class); } catch (final ClassNotFoundException cfne) { final String message = "Enum class not found"; throw new HibernateException(message, cfne); } final String identifierMethodName = parameters.getProperty("identifierMethod", DEFAULT_IDENTIFIER_METHOD_NAME); try { identifierMethod = enumClass.getMethod(identifierMethodName, new Class[0]); identifierType = identifierMethod.getReturnType(); } catch (final Exception e) { final String message = "Failed to obtain identifier method"; throw new HibernateException(message, e); } sqlTypes = new int[] { type.sqlType() }; final String valueOfMethodName = parameters.getProperty("valueOfMethod", DEFAULT_VALUE_OF_METHOD_NAME); try { valueOfMethod = enumClass.getMethod(valueOfMethodName, new Class[] { identifierType }); } catch (final Exception e) { final String message = "Failed to obtain valueOf method"; throw new HibernateException(message, e); } }
/** * {@inheritDoc} * * @throws SQLException * in case of database errors */ @Override public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException { if (value == null) { st.setNull(index, StandardBasicTypes.STRING.sqlType()); st.setNull(index + 1, StandardBasicTypes.BIG_DECIMAL.sqlType()); } else { Piece piece = (Piece) value; String unitType = piece.getUnitType().toString(); st.setString(index, unitType); st.setBigDecimal(index + 1, piece.getMagnitude()); } }
@Override public void nullSafeSet(final PreparedStatement st, final Object value, final int index) throws SQLException { try { if (value == null) { st.setNull(index, type.sqlType()); } else { final String identifier = (String) identifierMethod.invoke(value, new Object[0]); type.set(st, identifier, index); } } catch (final Exception e) { final String message = ExceptionManager.getInstance().getFullMessage("bh_GEUT_6", identifierMethod.getName(), enumClass); throw new HibernateException(message, e); } }
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if (value == null) { st.setNull(index, StandardBasicTypes.STRING.sqlType()); st.setNull(index + 1, StandardBasicTypes.STRING.sqlType()); } else { if (value instanceof Piece) {
@Override public void setParameterValues(final Properties parameters) { final String enumClassName = parameters.getProperty("enumClass"); try { enumClass = Class.forName(enumClassName).asSubclass(Enum.class); } catch (final ClassNotFoundException cfne) { final String message = ExceptionManager.getInstance().getFullMessage("bh_GEUT_1"); throw new HibernateException(message, cfne); } final String identifierMethodName = parameters.getProperty("identifierMethod", DEFAULT_IDENTIFIER_METHOD_NAME); Class<?> identifierType; try { identifierMethod = enumClass.getMethod(identifierMethodName, new Class[0]); identifierType = identifierMethod.getReturnType(); } catch (final Exception e) { final String message = ExceptionManager.getInstance().getFullMessage("bh_GEUT_2"); throw new HibernateException(message, e); } sqlTypes = new int[] { type.sqlType() }; final String valueOfMethodName = parameters.getProperty("valueOfMethod", DEFAULT_VALUE_OF_METHOD_NAME); try { valueOfMethod = enumClass.getMethod(valueOfMethodName, new Class[] { identifierType }); } catch (final Exception e) { final String message = ExceptionManager.getInstance().getFullMessage("bh_GEUT_4"); throw new HibernateException(message, e); } }