@Override public int hashCode() { //used also for generation of FK names! return isQuoted() ? name.hashCode() : name.toLowerCase( Locale.ROOT ).hashCode(); }
@SuppressWarnings("SimplifiableIfStatement") public boolean equals(Column column) { if ( null == column ) { return false; } if ( this == column ) { return true; } return isQuoted() ? name.equals( column.name ) : name.equalsIgnoreCase( column.name ); }
@Test public void testEscapeEntityField() { Table table = metadata().getEntityBinding( "org.hibernate.envers.test.integration.naming.quotation.QuotedFieldsEntity_AUD" ).getTable(); Column column1 = getColumnByName( table, "id" ); Column column2 = getColumnByName( table, "data1" ); Column column3 = getColumnByName( table, "data2" ); assert column1 != null; assert column2 != null; assert column3 != null; assert column1.isQuoted(); assert column2.isQuoted(); assert column3.isQuoted(); }
final ColumnInformation columnInfo = tableInfo.getColumn( Identifier.toIdentifier( column.getName(), column.isQuoted() ) );
private void doTestHbmQuoting(Class clazz) { Table table = metadata().getEntityBinding( clazz.getName() ).getTable(); assertTrue( table.isQuoted() ); Iterator itr = table.getColumnIterator(); while(itr.hasNext()) { Column column = (Column) itr.next(); assertTrue( column.isQuoted() ); } }
/** * Adds <code>column</code> element with the following attributes (unless empty): <code>name</code>, * <code>length</code>, <code>scale</code>, <code>precision</code>, <code>sql-type</code>, <code>read</code> * and <code>write</code>. * * @param anyMapping Parent element. * @param column Column descriptor. */ public static void addColumn(Element anyMapping, Column column) { addColumn( anyMapping, column.getName(), column.getLength(), column.getScale(), column.getPrecision(), column.getSqlType(), column.getCustomRead(), column.getCustomWrite(), column.isQuoted() ); }
public boolean equals(Column column) { if (null == column) return false; if (this == column) return true; return isQuoted() ? name.equals(column.name) : name.equalsIgnoreCase(column.name); }
public boolean equals(Column column) { if (null == column) return false; if (this == column) return true; return isQuoted() ? name.equals(column.name) : name.equalsIgnoreCase(column.name); }
public boolean equals(Column column) { if (null == column) return false; if (this == column) return true; return isQuoted() ? name.equals(column.name) : name.equalsIgnoreCase(column.name); }
public boolean equals(Column column) { if (null == column) return false; if (this == column) return true; return isQuoted() ? name.equals(column.name) : name.equalsIgnoreCase(column.name); }
public int hashCode() { return isQuoted() ? name.hashCode() : name.toLowerCase().hashCode(); }
public int hashCode() { return isQuoted() ? name.hashCode() : name.toLowerCase().hashCode(); }
public int hashCode() { return isQuoted() ? name.hashCode() : name.toLowerCase().hashCode(); }
public int hashCode() { return isQuoted() ? name.hashCode() : name.toLowerCase().hashCode(); }
private void bindLogicalToPhysical(String logicalName, Column physicalColumn) throws DuplicateMappingException { final String logicalKey = logicalName.toLowerCase(); final String physicalName = physicalColumn.getQuotedName(); final String existingPhysicalName = ( String ) logicalToPhysical.put( logicalKey, physicalName ); if ( existingPhysicalName != null ) { boolean areSamePhysicalColumn = physicalColumn.isQuoted() ? existingPhysicalName.equals( physicalName ) : existingPhysicalName.equalsIgnoreCase( physicalName ); if ( ! areSamePhysicalColumn ) { throw new DuplicateMappingException( " Table [" + tableName + "] contains logical column name [" + logicalName + "] referenced by multiple physical column names: [" + existingPhysicalName + "], [" + physicalName + "]", "column-binding", tableName + "." + logicalName ); } } }
private void bindLogicalToPhysical(String logicalName, Column physicalColumn) throws DuplicateMappingException { final String logicalKey = logicalName.toLowerCase(); final String physicalName = physicalColumn.getQuotedName(); final String existingPhysicalName = ( String ) logicalToPhysical.put( logicalKey, physicalName ); if ( existingPhysicalName != null ) { boolean areSamePhysicalColumn = physicalColumn.isQuoted() ? existingPhysicalName.equals( physicalName ) : existingPhysicalName.equalsIgnoreCase( physicalName ); if ( ! areSamePhysicalColumn ) { throw new DuplicateMappingException( " Table [" + tableName + "] contains logical column name [" + logicalName + "] referenced by multiple physical column names: [" + existingPhysicalName + "], [" + physicalName + "]", "column-binding", tableName + "." + logicalName ); } } }
public void addColumnBinding(String logicalName, Column finalColumn, Table table) { ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(table); if (binding == null) { binding = new ColumnNames(); columnNameBindingPerTable.put(table, binding); } String oldFinalName = (String) binding.logicalToPhysical.put( logicalName.toLowerCase(), finalColumn.getQuotedName() ); if ( oldFinalName != null && ! ( finalColumn.isQuoted() ? oldFinalName.equals( finalColumn.getQuotedName() ) : oldFinalName.equalsIgnoreCase( finalColumn.getQuotedName() ) ) ) { //TODO possibly relax that throw new MappingException("Same logical column name referenced by different physical ones: " + table.getName() + "." + logicalName + " => '" + oldFinalName + "' and '" + finalColumn.getQuotedName() + "'" ); } String oldLogicalName = (String) binding.physicalToLogical.put( finalColumn.getQuotedName(), logicalName ); if ( oldLogicalName != null && ! oldLogicalName.equals( logicalName ) ) { //TODO possibly relax that throw new MappingException("Same physical column represented by different logical column names: " + table.getName() + "." + finalColumn.getQuotedName() + " => '" + oldLogicalName + "' and '" + logicalName + "'"); } }
/** * Adds <code>column</code> element with the following attributes (unless empty): <code>name</code>, * <code>length</code>, <code>scale</code>, <code>precision</code>, <code>sql-type</code>, <code>read</code> * and <code>write</code>. * * @param anyMapping Parent element. * @param column Column descriptor. */ public static void addColumn(Element anyMapping, Column column) { addColumn( anyMapping, column.getName().getText(), column.getLength(), column.getScale(), column.getPrecision(), column.getSqlType(), column.getCustomRead(), column.getCustomWrite(), column.isQuoted() ); }