org.hibernate.type.Type.nullSafeGet()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中org.hibernate.type.Type.nullSafeGet()方法的一些代码示例,展示了Type.nullSafeGet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type.nullSafeGet()方法的具体详情如下:
包路径:org.hibernate.type.Type
类名称:Type
方法名:nullSafeGet

Type.nullSafeGet介绍

[英]Retrieve an instance of the mapped class from a JDBC resultset. Implementations should handle possibility of null values. This method might be called if the type is known to be a single-column type.
[中]从JDBC结果集中检索映射类的实例。实现应该处理空值的可能性。如果已知类型为单列类型,则可能会调用此方法。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Override
  public Object extract(Object[] data, ResultSet resultSet, SharedSessionContractImplementor session)
      throws SQLException, HibernateException {
    return type.nullSafeGet( resultSet, alias, session, null );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Object nullSafeGet(
    ResultSet rs,
    String name,
    SharedSessionContractImplementor session,
    Object owner) throws HibernateException, SQLException {
  Object key = baseType.nullSafeGet(rs, name, session, owner);
  return key==null ? null : discriminatorValuesToEntityNameMap.get(key);
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Object nullSafeGet(
    ResultSet rs,
    String[] names,
    SharedSessionContractImplementor session,
    Object owner) throws HibernateException, SQLException {
  Object key = baseType.nullSafeGet(rs, names, session, owner);
  return key==null ? null : discriminatorValuesToEntityNameMap.get(key);
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Object hydrate(ResultSet rs,	String[] names,	SharedSessionContractImplementor session,	Object owner)
    throws HibernateException, SQLException {
  final String entityName = (String) discriminatorType.nullSafeGet( rs, names[0], session, owner );
  final Serializable id = (Serializable) identifierType.nullSafeGet( rs, names[1], session, owner );
  return new ObjectTypeCacheEntry( entityName, id );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Object nullSafeGet(ResultSet rs,	String[] names,	SharedSessionContractImplementor session,	Object owner)
    throws HibernateException, SQLException {
  return resolveAny(
      (String) discriminatorType.nullSafeGet( rs, names[0], session, owner ),
      (Serializable) identifierType.nullSafeGet( rs, names[1], session, owner ),
      session
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Object readElement(ResultSet rs, Object owner, String[] aliases, SharedSessionContractImplementor session)
    throws HibernateException, SQLException {
  return getElementType().nullSafeGet( rs, aliases, session, owner );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected Object[] getResultRow(Object[] row, ResultSet rs, SharedSessionContractImplementor session)
    throws SQLException, HibernateException {
  Object[] resultRow;
  if ( hasScalars ) {
    String[][] scalarColumns = scalarColumnNames;
    int queryCols = queryReturnTypes.length;
    resultRow = new Object[queryCols];
    for ( int i = 0; i < queryCols; i++ ) {
      resultRow[i] = queryReturnTypes[i].nullSafeGet( rs, scalarColumns[i], session, null );
    }
  }
  else {
    resultRow = toResultRow( row );
  }
  return resultRow;
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Object hydrate(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException {
  return super.getIdentifierOrUniqueKeyType( session.getFactory() )
    .nullSafeGet(rs, names, session, owner);
}

代码示例来源:origin: hibernate/hibernate-orm

protected Serializable getResult(
      SharedSessionContractImplementor session,
      ResultSet rs,
      Object entity) throws SQLException {
    if ( !rs.next() ) {
      throw new IdentifierGenerationException(
          "the inserted row could not be located by the unique key: " +
              uniqueKeyPropertyName
      );
    }
    return (Serializable) idType.nullSafeGet(
        rs,
        persister.getRootTableKeyColumnNames(),
        session,
        entity
    );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected Object[] getResultRow(Object[] row, ResultSet rs, SharedSessionContractImplementor session)
    throws SQLException, HibernateException {
  Object[] resultRow;
  if ( hasScalars ) {
    String[][] scalarColumns = getColumnNames();
    int queryCols = returnTypes.length;
    resultRow = new Object[queryCols];
    for ( int i = 0; i < queryCols; i++ ) {
      resultRow[i] = returnTypes[i].nullSafeGet( rs, scalarColumns[i], session, null );
    }
  }
  else {
    resultRow = toResultRow( row );
  }
  return resultRow;
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Object readIdentifier(ResultSet rs, String alias, SharedSessionContractImplementor session)
    throws HibernateException, SQLException {
  Object id = getIdentifierType().nullSafeGet( rs, alias, session, null );
  if ( id == null ) {
    throw new HibernateException( "null identifier column for collection: " + navigableRole.getFullPath() );
  }
  return id;
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Object readIndex(ResultSet rs, String[] aliases, SharedSessionContractImplementor session)
    throws HibernateException, SQLException {
  Object index = getIndexType().nullSafeGet( rs, aliases, session, null );
  if ( index == null ) {
    throw new HibernateException( "null index column for collection: " + navigableRole.getFullPath() );
  }
  index = decrementIndexByBase( index );
  return index;
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected Object[] getResultRow(Object[] row, ResultSet rs, SharedSessionContractImplementor session)
    throws SQLException, HibernateException {
  final Object[] result;
  if ( translator.hasProjection() ) {
    Type[] types = translator.getProjectedTypes();
    result = new Object[types.length];
    String[] columnAliases = translator.getProjectedColumnAliases();
    for ( int i=0, pos=0; i<result.length; i++ ) {
      int numColumns = types[i].getColumnSpan( session.getFactory() );
      if ( numColumns > 1 ) {
        String[] typeColumnAliases = ArrayHelper.slice( columnAliases, pos, numColumns );
        result[i] = types[i].nullSafeGet(rs, typeColumnAliases, session, null);
      }
      else {
        result[i] = types[i].nullSafeGet(rs, columnAliases[pos], session, null);
      }
      pos += numColumns;
    }
  }
  else {
    result = toResultRow( row );
  }
  return result;
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Object nullSafeGet(
    ResultSet rs,
    String name,
    SharedSessionContractImplementor session,
    Object owner) throws HibernateException, SQLException {
  final Object discriminatorValue = underlyingType.nullSafeGet( rs, name, session, owner );
  final String entityName = persister.getSubclassForDiscriminatorValue( discriminatorValue );
  if ( entityName == null ) {
    throw new HibernateException( "Unable to resolve discriminator value [" + discriminatorValue + "] to entity name" );
  }
  final EntityPersister entityPersister = session.getEntityPersister( entityName, null );
  return ( EntityMode.POJO == entityPersister.getEntityMode() ) ? entityPersister.getMappedClass() : entityName;
}

代码示例来源:origin: hibernate/hibernate-orm

currentResult = types[0].nullSafeGet( rs, names[0], session, null );
  currentResults[i] = types[i].nullSafeGet( rs, names[i], session, null );

代码示例来源:origin: hibernate/hibernate-orm

resultId = (Serializable) idType.nullSafeGet(
    rs,
    getEntityAliases()[i].getSuffixedKeyAliases(),

代码示例来源:origin: hibernate/hibernate-orm

final Object discriminatorValue = persister.getDiscriminatorType().nullSafeGet(
    rs,
    getEntityAliases()[i].getSuffixedDiscriminatorAlias(),

代码示例来源:origin: hibernate/hibernate-orm

try {
  if ( rs.next() ) {
    return getElementType().nullSafeGet( rs, elementColumnAliases, session, owner );

代码示例来源:origin: hibernate/hibernate-orm

discriminatorValue = loadable.getDiscriminatorType().nullSafeGet(
    resultSet,
    entityReferenceAliases.getColumnAliases().getSuffixedDiscriminatorAlias(),

代码示例来源:origin: hibernate/hibernate-orm

return null;
return (Serializable) getIdentifierType().nullSafeGet( rs, getIdentifierAliases(), session, null );

相关文章