org.hibernate.mapping.Column.getSqlTypeCode()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(92)

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

Column.getSqlTypeCode介绍

[英]Returns the underlying columns sqltypecode. If null, it is because the sqltype code is unknown.

Use #getSqlTypeCode(Mapping) to retrieve the sqltypecode used for the columns associated Value/Type.
[中]返回基础列sqltypecode。如果为null,则是因为sqltype代码未知。
使用#getSqlTypeCode(映射)检索用于关联值/类型的列的sqltypecode。

代码示例

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

public int getSqlTypeCode(Mapping mapping) throws MappingException {
  org.hibernate.type.Type type = getValue().getType();
  try {
    int sqlTypeCode = type.sqlTypes( mapping )[getTypeIndex()];
    if ( getSqlTypeCode() != null && getSqlTypeCode() != sqlTypeCode ) {
      throw new MappingException( "SQLType code's does not match. mapped as " + sqlTypeCode + " but is " + getSqlTypeCode() );
    }
    return sqlTypeCode;
  }
  catch (Exception e) {
    throw new MappingException(
        "Could not determine type for column " +
            name +
            " of type " +
            type.getClass().getName() +
            ": " +
            e.getClass().getName(),
        e
    );
  }
}

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

public String getSqlType(Dialect dialect, Mapping mapping) throws HibernateException {
  if ( sqlType == null ) {
    sqlType = dialect.getTypeName( getSqlTypeCode( mapping ), getLength(), getPrecision(), getScale() );
  }
  return sqlType;
}

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

ExecutionOptions options,
  Dialect dialect) {
boolean typesMatch = column.getSqlTypeCode( metadata ) == columnInformation.getTypeCode()
    || column.getSqlType( dialect, metadata ).toLowerCase(Locale.ROOT).startsWith( columnInformation.getTypeName().toLowerCase(Locale.ROOT) );
if ( !typesMatch ) {
          JdbcTypeNameMapper.getTypeName( columnInformation.getTypeCode() ),
          column.getSqlType().toLowerCase(Locale.ROOT),
          JdbcTypeNameMapper.getTypeName( column.getSqlTypeCode( metadata ) )

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

Column col = (Column) citer.next();
if ( !table.containsColumn( col ) ) {
  int sqlType = col.getSqlTypeCode( mapping );
  buf.append( dialect.getSelectClauseNullString( sqlType ) )
      .append( " as " );

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

.append( dialect.getIdentityColumnSupport().getIdentityColumnString( col.getSqlTypeCode( p ) ) );

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

public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) {
  Iterator iter = getColumnIterator();
  while ( iter.hasNext() ) {
    Column col = (Column) iter.next();
    ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() );
    if ( columnInfo == null ) {
      throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()));
    }
    else {
      final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase(Locale.ROOT)
          .startsWith( columnInfo.getTypeName().toLowerCase(Locale.ROOT) )
          || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping );
      if ( !typesMatch ) {
        throw new HibernateException(
            "Wrong column type in " +
            Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) +
            " for column " + col.getName() +
            ". Found: " + columnInfo.getTypeName().toLowerCase(Locale.ROOT) +
            ", expected: " + col.getSqlType( dialect, mapping )
        );
      }
    }
  }
}

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

.append( dialect.getIdentityColumnSupport().getIdentityColumnString( col.getSqlTypeCode( metadata ) ) );

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

public int getSqlTypeCode(Mapping mapping) throws MappingException {
  org.hibernate.type.Type type = getValue().getType();
  try {
    int sqlTypeCode = type.sqlTypes(mapping)[ getTypeIndex() ];
    if(getSqlTypeCode()!=null && getSqlTypeCode().intValue()!=sqlTypeCode) {
      throw new MappingException("SQLType code's does not match. mapped as " + sqlTypeCode + " but is " + getSqlTypeCode() );
    }
    return sqlTypeCode;
  }
  catch (Exception e) {
    throw new MappingException(
        "Could not determine type for column " +
        name +
        " of type " +
        type.getClass().getName() +
        ": " +
        e.getClass().getName(),
        e
      );
  }
}

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

public int getSqlTypeCode(Mapping mapping) throws MappingException {
  org.hibernate.type.Type type = getValue().getType();
  try {
    int sqlTypeCode = type.sqlTypes(mapping)[ getTypeIndex() ];
    if(getSqlTypeCode()!=null && getSqlTypeCode().intValue()!=sqlTypeCode) {
      throw new MappingException("SQLType code's does not match. mapped as " + sqlTypeCode + " but is " + getSqlTypeCode() );
    }
    return sqlTypeCode;
  }
  catch (Exception e) {
    throw new MappingException(
      "Could not determine type for column " +
      name +
      " of type " +
      type.getClass().getName() +
      ": " +
      e.getClass().getName(),
      e
    );
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

public int getSqlTypeCode(Mapping mapping) throws MappingException {
  org.hibernate.type.Type type = getValue().getType();
  try {
    int sqlTypeCode = type.sqlTypes( mapping )[getTypeIndex()];
    if ( getSqlTypeCode() != null && getSqlTypeCode() != sqlTypeCode ) {
      throw new MappingException( "SQLType code's does not match. mapped as " + sqlTypeCode + " but is " + getSqlTypeCode() );
    }
    return sqlTypeCode;
  }
  catch ( Exception e ) {
    throw new MappingException(
        "Could not determine type for column " +
            name +
            " of type " +
            type.getClass().getName() +
            ": " +
            e.getClass().getName(),
        e
    );
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

public int getSqlTypeCode(Mapping mapping) throws MappingException {
  org.hibernate.type.Type type = getValue().getType();
  try {
    int sqlTypeCode = type.sqlTypes( mapping )[getTypeIndex()];
    if ( getSqlTypeCode() != null && getSqlTypeCode() != sqlTypeCode ) {
      throw new MappingException( "SQLType code's does not match. mapped as " + sqlTypeCode + " but is " + getSqlTypeCode() );
    }
    return sqlTypeCode;
  }
  catch ( Exception e ) {
    throw new MappingException(
        "Could not determine type for column " +
            name +
            " of type " +
            type.getClass().getName() +
            ": " +
            e.getClass().getName(),
        e
    );
  }
}

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

public String getSqlType(Dialect dialect, Mapping mapping) throws HibernateException {
  return sqlType==null ?
    dialect.getTypeName( getSqlTypeCode(mapping), getLength(), getPrecision(), getScale() ) :
    sqlType;
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

public String getSqlType(Dialect dialect, Mapping mapping) throws HibernateException {
  return sqlType==null ?
    dialect.getTypeName( getSqlTypeCode(mapping), getLength(), getPrecision(), getScale() ) :
    sqlType;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

public String getSqlType(Dialect dialect, Mapping mapping) throws HibernateException {
  if ( sqlType == null ) {
    sqlType = dialect.getTypeName( getSqlTypeCode( mapping ), getLength(), getPrecision(), getScale() );
  }
  return sqlType;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

public String getSqlType(Dialect dialect, Mapping mapping) throws HibernateException {
  if ( sqlType == null ) {
    sqlType = dialect.getTypeName( getSqlTypeCode( mapping ), getLength(), getPrecision(), getScale() );
  }
  return sqlType;
}

代码示例来源:origin: org.hibernate/hibernate-tools

public void visit(
    Table table, 
    Column col,
    IssueCollector pc) {
  if ( currentDbTable == null ) {
    return;
  }
  Column dbColumn = currentDbTable
      .getColumn( new Column( col.getName() ) );
  if ( dbColumn == null ) {
    pc.reportIssue( new Issue( "SCHEMA_COLUMN_MISSING",
        Issue.HIGH_PRIORITY, table(table) + " is missing column: " + col.getName() ) );
  }
  else {
    //TODO: this needs to be able to know if a type is truly compatible or not. Right now it requires an exact match.
    //String sqlType = col.getSqlType( dialect, mapping );
    int dbTypeCode = dbColumn.getSqlTypeCode().intValue();
    int modelTypeCode = col
              .getSqlTypeCode( mapping );
    // TODO: sqltype name string
    if ( !(dbTypeCode == modelTypeCode ) ) {
      pc.reportIssue( new Issue( "SCHEMA_COLUMN_TYPE_MISMATCH",
          Issue.NORMAL_PRIORITY, table(table) + " has a wrong column type for "
              + col.getName() + ", expected: "
              + JDBCToHibernateTypeHelper.getJDBCTypeName(modelTypeCode) + " but was " + JDBCToHibernateTypeHelper.getJDBCTypeName(dbTypeCode) + " in db") );
    }
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) {
  Iterator iter = getColumnIterator();
  while ( iter.hasNext() ) {
    Column col = (Column) iter.next();
    ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() );
    if ( columnInfo == null ) {
      throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()));
    }
    else {
      final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase()
          .startsWith( columnInfo.getTypeName().toLowerCase() )
          || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping );
      if ( !typesMatch ) {
        throw new HibernateException(
            "Wrong column type in " +
            Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) +
            " for column " + col.getName() +
            ". Found: " + columnInfo.getTypeName().toLowerCase() +
            ", expected: " + col.getSqlType( dialect, mapping )
        );
      }
    }
  }
}

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

public void visit(
    Table table, 
    Column col,
    IssueCollector pc) {
  if ( currentDbTable == null ) {
    return;
  }
  Column dbColumn = currentDbTable
      .getColumn( new Column( col.getName() ) );
  if ( dbColumn == null ) {
    pc.reportIssue( new Issue( "SCHEMA_COLUMN_MISSING",
        Issue.HIGH_PRIORITY, table(table) + " is missing column: " + col.getName() ) );
  }
  else {
    //TODO: this needs to be able to know if a type is truly compatible or not. Right now it requires an exact match.
    //String sqlType = col.getSqlType( dialect, mapping );
    int dbTypeCode = dbColumn.getSqlTypeCode().intValue();
    int modelTypeCode = col
              .getSqlTypeCode( mapping );
    // TODO: sqltype name string
    if ( !(dbTypeCode == modelTypeCode ) ) {
      pc.reportIssue( new Issue( "SCHEMA_COLUMN_TYPE_MISMATCH",
          Issue.NORMAL_PRIORITY, table(table) + " has a wrong column type for "
              + col.getName() + ", expected: "
              + JdbcToHibernateTypeHelper.getJDBCTypeName(modelTypeCode) + " but was " + JdbcToHibernateTypeHelper.getJDBCTypeName(dbTypeCode) + " in db") );
    }
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) {
  Iterator iter = getColumnIterator();
  while ( iter.hasNext() ) {
    Column col = (Column) iter.next();
    ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() );
    if ( columnInfo == null ) {
      throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()));
    }
    else {
      final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase()
          .startsWith( columnInfo.getTypeName().toLowerCase() )
          || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping );
      if ( !typesMatch ) {
        throw new HibernateException(
            "Wrong column type in " +
            Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) +
            " for column " + col.getName() +
            ". Found: " + columnInfo.getTypeName().toLowerCase() +
            ", expected: " + col.getSqlType( dialect, mapping )
        );
      }
    }
  }
}

代码示例来源:origin: com.vecna/dbDiff-hibernate

ColumnType type = new ColumnType(mappedColumn.getSqlTypeCode(m_mapping), mappedColumn.getSqlType(m_dialect, m_mapping));
column.setColumnType(type);

相关文章