public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { String first = StringType.INSTANCE.nullSafeGet( rs, names[0], session ); String second = StringType.INSTANCE.nullSafeGet( rs, names[1], session ); return ( first == null && second == null ) ? null : new String[] {first, second}; }
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { String[] strings = ( value == null ) ? new String[2] : (String[]) value; StringType.INSTANCE.nullSafeSet( st, strings[0], index, session ); StringType.INSTANCE.nullSafeSet( st, strings[1], index + 1, session ); }
@Override public int[] sqlTypes() { return new int[] {StringType.INSTANCE.sqlType()}; }
@Override public String objectToSQLString(Boolean value, Dialect dialect) throws Exception { return StringType.INSTANCE.objectToSQLString( value ? "Y" : "N", dialect ); } }
addEntity("mods", Modification.class). addScalar("pmrPipelineId", new LongType()). addScalar("pmrPipelineName", new StringType()). addScalar("materialType", new StringType()). addScalar("fingerprint", new StringType()). setParameterList("ids", CollectionUtil.map(relevantToLookedUpMap.keySet(), PipelineId.MAP_ID)). list();
public String getName() { return StringType.INSTANCE.getName(); }
@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); } }
@SuppressWarnings("rawtypes") @Override public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { JsonHolder jsonHolder = (JsonHolder) value; if (jsonHolder != null && jsonHolder.getValue() != null) { StringType.INSTANCE.set(st, jsonHolder.getValue().getClass().getName(), index, session); TextType.INSTANCE.set(st, jsonSerializationService.toJson(jsonHolder.getValue()), index + 1, session); } else { StringType.INSTANCE.set(st, null, index, session); TextType.INSTANCE.set(st, null, index + 1, session); } }
@Override public String objectToSQLString(Boolean value, Dialect dialect) throws Exception { return StringType.INSTANCE.objectToSQLString( value ? "T" : "F", dialect ); }
private Map<PipelineId, Set<Long>> relevantToLookedUpDependencyMap(Session session, List<Long> pipelineIds) { final int LOOKED_UP_PIPELINE_ID = 2; final int RELEVANT_PIPELINE_ID = 0; final int RELEVANT_PIPELINE_NAME = 1; String pipelineIdsSql = queryExtensions.queryRelevantToLookedUpDependencyMap(pipelineIds); SQLQuery pipelineIdsQuery = session.createSQLQuery(pipelineIdsSql); pipelineIdsQuery.addScalar("id", new LongType()); pipelineIdsQuery.addScalar("name", new StringType()); pipelineIdsQuery.addScalar("lookedUpId", new LongType()); final List<Object[]> ids = pipelineIdsQuery.list(); Map<Long, List<PipelineId>> lookedUpToParentMap = new HashMap<>(); CollectionUtil.CollectionValueMap<Long, PipelineId> lookedUpToRelevantMap = CollectionUtil.collectionValMap(lookedUpToParentMap, new CollectionUtil.ArrayList<>()); for (Object[] relevantAndLookedUpId : ids) { lookedUpToRelevantMap.put((Long) relevantAndLookedUpId[LOOKED_UP_PIPELINE_ID], new PipelineId((String) relevantAndLookedUpId[RELEVANT_PIPELINE_NAME], (Long) relevantAndLookedUpId[RELEVANT_PIPELINE_ID])); } return CollectionUtil.reverse(lookedUpToParentMap); }
registerHibernateType( Types.CHAR, StandardBasicTypes.CHARACTER.getName() ); registerHibernateType( Types.CHAR, 1, StandardBasicTypes.CHARACTER.getName() ); registerHibernateType( Types.CHAR, 255, StandardBasicTypes.STRING.getName() ); registerHibernateType( Types.DATE, StandardBasicTypes.DATE.getName() ); registerHibernateType( Types.DOUBLE, StandardBasicTypes.DOUBLE.getName() ); registerHibernateType( Types.TIME, StandardBasicTypes.TIME.getName() ); registerHibernateType( Types.TIMESTAMP, StandardBasicTypes.TIMESTAMP.getName() ); registerHibernateType( Types.VARCHAR, StandardBasicTypes.STRING.getName() ); registerHibernateType( Types.NVARCHAR, StandardBasicTypes.NSTRING.getName() ); registerHibernateType( Types.VARBINARY, StandardBasicTypes.BINARY.getName() );
@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(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { BigDecimalType.INSTANCE.set(st, null, index, session); StringType.INSTANCE.set(st, null, index + 1, session); } else { Money money = (Money) value; BigDecimalType.INSTANCE.set(st, money.getAmount(), index, session); StringType.INSTANCE.set(st, money.getCurrencyUnit().getCurrencyCode(), index + 1, session); } }
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { return StringType.INSTANCE.nullSafeGet( rs, names[0], session ); }
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( value != null ) { String v = (String) value; if ( !v.startsWith( param1 ) ) { v = param1 + v; } if ( !v.endsWith( param2 ) ) { v = v + param2; } StringType.INSTANCE.nullSafeSet( st, v, index, session ); } else { StringType.INSTANCE.nullSafeSet( st, null, index, session ); } }
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() ); } }
public String objectToSQLString(UUID value, Dialect dialect) throws Exception { return StringType.INSTANCE.objectToSQLString( value.toString(), dialect ); } }
public List<MessageExtDto> getMessagesForProfile2(Long userProfileId) { Query query = getSession().createSQLQuery(" " + " select a.*, b.* " + " from messageVO AS a " + " INNER JOIN ( SELECT max(id) AS id, count(*) AS count FROM messageVO GROUP BY messageConversation_id) as b ON a.id = b.id " + " where a.id > 0 " + " ") .addScalar("id", new LongType()) .addScalar("message", new StringType()) ......... your mappings .setResultTransformer(Transformers.aliasToBean(MessageExtDto.class)); List<MessageExtDto> list = query.list(); return list; }
registerHibernateType( Types.CLOB, StandardBasicTypes.MATERIALIZED_CLOB.getName() ); registerHibernateType( Types.BLOB, StandardBasicTypes.MATERIALIZED_BLOB.getName() ); registerHibernateType( Types.NVARCHAR, StandardBasicTypes.STRING.getName() );
@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); } }