Java Code Examples for org.hibernate.tool.hbm2ddl.ColumnMetadata#getTypeCode()

The following examples show how to use org.hibernate.tool.hbm2ddl.ColumnMetadata#getTypeCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Table.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 )
					.startsWith( columnInfo.getTypeName().toLowerCase() )
					|| columnInfo.getTypeCode() == col.getSqlTypeCode( mapping );
			if ( !typesMatch ) {
				throw new HibernateException(
						"Wrong column type: " + col.getName() +
								", expected: " + col.getSqlType( dialect, mapping )
				);
			}
		}
	}

}
 
Example 2
Source File: Table.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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 )
				);
			}
		}
	}

}
 
Example 3
Source File: Table.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
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 )
				);
			}
		}
	}

}
 
Example 4
Source File: Table.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
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 )
				);
			}
		}
	}

}
 
Example 5
Source File: Table.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
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 )
				);
			}
		}
	}

}
 
Example 6
Source File: Table.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
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 )
				);
			}
		}
	}

}
 
Example 7
Source File: Table.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
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 )
				);
			}
		}
	}

}