private boolean propertyIteratorContainsColumn(Iterator propertyIterator, Column column) { for ( Iterator it = propertyIterator; it.hasNext(); ) { final Property property = (Property) it.next(); for ( Iterator<Selectable> selectableIterator = property.getColumnIterator(); selectableIterator.hasNext(); ) { final Selectable selectable = selectableIterator.next(); if ( column.equals( selectable ) ) { final Column iteratedColumn = (Column) selectable; if ( column.getValue().getTable().equals( iteratedColumn.getValue().getTable() ) ) { return true; } } } } return false; }
protected String getTableNameForLogging(Column column) { if ( getTable() != null ) { if ( getTable().getNameIdentifier() != null ) { return getTable().getNameIdentifier().getCanonicalName(); } else { return "<unknown>"; } } else if ( column.getValue() != null && column.getValue().getTable() != null ) { return column.getValue().getTable().getNameIdentifier().getCanonicalName(); } return "<unknown>"; }
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 ); } }
@Test @TestForIssue(jiraKey = "HHH-5848") public void testDatabaseTableNames() { PersistentClass classMapping = metadata().getEntityBinding( Item.class.getName() ); Column secTabColumn = (Column) classMapping.getProperty( "specialPrice" ).getColumnIterator().next(); assertEquals( "TAB_ITEMS_SEC", secTabColumn.getValue().getTable().getName() ); Column tabColumn = (Column) classMapping.getProperty( "price" ).getColumnIterator().next(); assertEquals( "TAB_ITEMS", tabColumn.getValue().getTable().getName() ); } }
private void checkColumn(Column column) { if(column.getValue()!=null) { //throw new JDBCBinderException("Binding column twice should not happen. " + column); } }
private void checkColumn(Column column) { if(column.getValue()!=null) { //throw new JDBCBinderException("Binding column twice should not happen. " + column); } }
/** * Method to generate a random value for use in setting WebTest parameters * @param column the type of object (i.e. "java.util.Date") * @return The string-ified version of the date */ public String getValueForWebTest(Column column) { String type = column.getValue().getType().getReturnedClass().getName(); String value = getTestValueForDbUnit(column); if (type.equalsIgnoreCase(Date.class.getName())) { value = getDate(new Date(), uiDatePattern); } else if ("boolean".equals(type) || "java.lang.Boolean".equals(type)) { value = "true"; } return value; }
String type = column.getValue().getType().getReturnedClass().getName();
String type = column.getValue().getType().getReturnedClass().getName();
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 ); } }
private String fieldType(Column currentColumn) { TypeTranslator translator = serviceRegistry.getService( TypeTranslator.class ); Type valueType = currentColumn.getValue().getType(); GridType gridType = translator.getType( valueType ); if ( gridType instanceof EnumType ) { return enumFieldType( (EnumType) gridType ); } if ( gridType instanceof YesNoType ) { return STRING_CLASS_NAME; } if ( gridType instanceof NumericBooleanType ) { return INTEGER_CLASS_NAME; } Class<?> returnedClass = valueType.getReturnedClass(); if ( Character.class.equals( returnedClass ) ) { return STRING_CLASS_NAME; } return returnedClass.getName(); }
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 ); } }
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 ); } }
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 ); } }
@Override public ParameterMetadata buildParameterMetadata(String nativeQuery) { PreparedStatement preparedStatement = session.prepare( nativeQuery ); ColumnDefinitions columnDefinitions = preparedStatement.getVariables(); OrdinalParameterDescriptor[] ordinalDescriptors = new OrdinalParameterDescriptor[columnDefinitions.size()]; if ( columnDefinitions.size() > 0 ) { // the cassandra metadata will give us the CQL type, but the type conversion system only goes // in hibernate->cassandra direction, so we can't turn it back into the required hibernate type. // instead we rely on the cached hibernate metadata from schema creation time String tableName = columnDefinitions.getTable( 0 ); Table table = metaDataCache.get( tableName ); for ( ColumnDefinitions.Definition definition : columnDefinitions ) { String name = definition.getName(); Column column = table.getColumn( Identifier.toIdentifier( name ) ); Type hibernateType = column.getValue().getType(); // cassandra side index is 0-based, hibernate side index is 1-based int index = columnDefinitions.getIndexOf( name ); ordinalDescriptors[index] = new OrdinalParameterDescriptor( index + 1, hibernateType, 0 ); } } return new ParameterMetadata( ordinalDescriptors, null ); } }
column.setColumnSize(mappedColumn.getPrecision()); } else if ("character".equals(mappedColumn.getValue().getType().getName())) { column.setColumnSize(1); } else if (!"binary".equals(mappedColumn.getValue().getType().getName()) && mappedColumn.getLength() != org.hibernate.mapping.Column.DEFAULT_LENGTH) { column.setColumnSize(mappedColumn.getLength());
SimpleValue id = (SimpleValue) col.getValue();
SimpleValue id = (SimpleValue) col.getValue();