statement.setNull(parameterIndex + i + 1, type.sqlType());
@Override public final void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( settable[0] ) { nullSafeSet( st, value, index, session ); } } }
@Override public final int sqlType() { return getSqlTypeDescriptor().getSqlType(); }
assertTrue( original == type.replace( original, copy, null, null, null ) ); new Object[]{ LazyPropertyInitializer.UNFETCHED_PROPERTY }, types, null, null, null )[0] ); assertTrue( type.isSame( original, copy ) ); assertTrue( type.isEqual( original, copy ) ); assertTrue( type.isEqual( original, copy ) ); assertTrue( type.isEqual( original, copy, null ) ); assertFalse( type.isSame( original, different ) ); assertFalse( type.isEqual( original, different ) ); assertFalse( type.isEqual( original, different ) ); assertFalse( type.isEqual( original, different, null ) ); assertFalse( type.isDirty( original, copy , session ) ); assertFalse( type.isDirty( original, copy , ArrayHelper.FALSE, session ) ); assertFalse( type.isDirty( original, copy , ArrayHelper.TRUE, session ) ); assertTrue( type.isDirty( original, different , session ) ); assertFalse( type.isDirty( original, different , ArrayHelper.FALSE, session ) ); assertTrue( type.isDirty( original, different , ArrayHelper.TRUE, session ) ); assertFalse( type.isModified( original, copy, ArrayHelper.FALSE, session ) ); assertFalse( type.isModified( original, copy, ArrayHelper.TRUE, session ) ); assertTrue( type.isModified( original, different, ArrayHelper.FALSE, session ) ); assertTrue( type.isModified( original, different, ArrayHelper.TRUE, session ) );
@Override public void doNullSafeSet(PreparedStatement preparedStatement, Object value, int index, SharedSessionContractImplementor session) throws SQLException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (value == null) { preparedStatement.setNull(index, getType().sqlType()); } else { @SuppressWarnings("unchecked") final Object identifier = binding.marshal(value); getType().nullSafeSet(preparedStatement, identifier, index, session); } } }
Number[] levelNumbers = new Number[levelsSize]; for (int i = 0; i < levelsSize; i++) { Number levelNumber = (Number) type.nullSafeGet(resultSet, names[i + 1], session, owner); if (levelNumber == null) { nullCount++;
@Override public Object doNullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Object identifier = getType().get(rs, names[0], session); if (rs.wasNull()) { return null; } @SuppressWarnings("unchecked") final Object result = binding.unmarshal(identifier); return result; }
@Override public void doNullSafeSet(PreparedStatement preparedStatement, Object value, int index, SharedSessionContractImplementor session) throws SQLException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (value == null) { preparedStatement.setNull(index, getType().sqlType()); } else { try { String identifier = objectWriter.writeValueAsString(value); getType().nullSafeSet(preparedStatement, identifier, index, session); } catch (JsonProcessingException e) { throw new HibernateException("Problem writing JSON String: " + e.getMessage(), e); } } }
@Override public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { Date date = (Date) HIBERNATE_TYPE.nullSafeGet(rs, names[0], session); if (date == null) { return null; } return asXMLGregorianCalendar(date); }
@Override public Object doNullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { String jsonText = (String) getType().get(rs, names[0], session); if (rs.wasNull()) { return null; } Object obj; try { obj = getObjectReader().readValue(jsonText); } catch (JsonParseException e) { throw new HibernateException("Problem parsing retrieved JSON String: " + jsonText, e); } catch (JsonMappingException e) { throw new HibernateException("Problem mapping retrieved JSON String: " + jsonText, e); } catch (IOException e) { throw new HibernateException("Problem reading JSON String: " + jsonText, e); } return obj; }
@Override public int[] sqlTypes() { return new int[]{HIBERNATE_TYPE.sqlType()}; }
/** * {@inheritDoc} */ public final void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session) throws HibernateException, SQLException { if ( settable[0] ) { nullSafeSet( st, value, index, session ); } } }
private void resolveLob(final SingularAttributeSourceBasic attributeSource, SimpleValue value) { // Resolves whether the property is LOB based on the type attribute on the attribute property source. // Essentially this expects the type to map to a CLOB/NCLOB/BLOB sql type internally and compares. if ( !value.isLob() && value.getTypeName() != null ) { final TypeResolver typeResolver = attributeSource.getBuildingContext().getMetadataCollector().getTypeResolver(); final BasicType basicType = typeResolver.basic( value.getTypeName() ); if ( basicType instanceof AbstractSingleColumnStandardBasicType ) { if ( isLob( ( (AbstractSingleColumnStandardBasicType) basicType ).getSqlTypeDescriptor().getSqlType(), null ) ) { value.makeLob(); } } } // If the prior check didn't set the lob flag, this will inspect the column sql-type attribute value and // if this maps to CLOB/NCLOB/BLOB then the value will be marked as lob. if ( !value.isLob() ) { for ( RelationalValueSource relationalValueSource : attributeSource.getRelationalValueSources() ) { if ( ColumnSource.class.isInstance( relationalValueSource ) ) { if ( isLob( null, ( (ColumnSource) relationalValueSource ).getSqlType() ) ) { value.makeLob(); } } } } }
Number[] levelNumbers = new Number[levelsSize]; for (int i = 0; i < levelsSize; i++) { Number levelNumber = (Number) type.nullSafeGet(resultSet, names[i + 1], session, owner); if (levelNumber == null) { nullCount++;
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { try { if (value == null) { st.setNull(index, ((AbstractSingleColumnStandardBasicType<?>) type).sqlType()); } else { Object identifier = identifierMethod.invoke(value, new Object[0]); type.nullSafeSet(st, identifier, index, null); } } catch (Exception e) { throw new HibernateException("Exception while invoking identifierMethod '" + identifierMethod.getName() + "' of " + "enumeration class '" + enumClass + "'", e); } }
/** * {@inheritDoc} */ public final void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session) throws HibernateException, SQLException { if ( settable[0] ) { nullSafeSet( st, value, index, session ); } } }
public final int sqlType() { return getSqlTypeDescriptor().getSqlType(); } }
@Override public void nullSafeSet(final PreparedStatement st, final Object value, final int index, final SharedSessionContractImplementor ssci) throws HibernateException, SQLException { try { if (value == null) { st.setNull(index, ((AbstractSingleColumnStandardBasicType<?>) type).sqlType()); } else { Object identifier = identifierMethod.invoke(value, new Object[0]); type.nullSafeSet(st, identifier, index, ssci); } } catch (Exception e) { throw new HibernateException("Exception while invoking identifierMethod '" + identifierMethod.getName() + "' of " + "enumeration class '" + enumClass + "'", e); } }
@Override public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { XMLGregorianCalendar calendar = (XMLGregorianCalendar) value; Date date = null; if (calendar != null) { date = asDate(calendar); } HIBERNATE_TYPE.nullSafeSet(st, date, index, session); }
public final int sqlType() { return getSqlTypeDescriptor().getSqlType(); }