HHH-6366 : Add integer value to uniquely identify Table and InLineView objects for column aliases
This commit is contained in:
parent
4febfe4d82
commit
6499491374
|
@ -28,6 +28,7 @@ import java.util.Collections;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Convenience base class for implementing the {@link ValueContainer} contract centralizing commonality
|
||||
|
@ -36,10 +37,21 @@ import java.util.List;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractTableSpecification implements TableSpecification, ValueContainer {
|
||||
private final static AtomicInteger tableCounter = new AtomicInteger( 0 );
|
||||
private final int tableNumber;
|
||||
private final LinkedHashMap<String,SimpleValue> values = new LinkedHashMap<String,SimpleValue>();
|
||||
private PrimaryKey primaryKey = new PrimaryKey( this );
|
||||
private List<ForeignKey> foreignKeys = new ArrayList<ForeignKey>();
|
||||
|
||||
public AbstractTableSpecification() {
|
||||
this.tableNumber = tableCounter.getAndIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTableNumber() {
|
||||
return tableNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<SimpleValue> values() {
|
||||
return values.values();
|
||||
|
|
|
@ -36,6 +36,13 @@ public interface TableSpecification extends ValueContainer, Loggable {
|
|||
*/
|
||||
public Schema getSchema();
|
||||
|
||||
/**
|
||||
* Get the table number.
|
||||
*
|
||||
* @return the table number.
|
||||
*/
|
||||
public int getTableNumber();
|
||||
|
||||
/**
|
||||
* Get the primary key definition for this table spec.
|
||||
*
|
||||
|
|
|
@ -85,6 +85,21 @@ public class TableManipulationTests extends BaseUnitTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTableSpecificationCounter() {
|
||||
Schema schema = new Schema( null, null );
|
||||
Table table = schema.createTable( Identifier.toIdentifier( "my_table" ) );
|
||||
InLineView inLineView = schema.createInLineView( "my_inlineview", "subselect" );
|
||||
InLineView otherInLineView = schema.createInLineView( "my_other_inlineview", "other subselect" );
|
||||
Table otherTable = schema.createTable( Identifier.toIdentifier( "my_other_table" ) );
|
||||
|
||||
int firstTableNumber = table.getTableNumber();
|
||||
assertEquals( firstTableNumber, table.getTableNumber() );
|
||||
assertEquals( firstTableNumber + 1, inLineView.getTableNumber() );
|
||||
assertEquals( firstTableNumber + 2, otherInLineView.getTableNumber() );
|
||||
assertEquals( firstTableNumber + 3, otherTable.getTableNumber() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicForeignKeyDefinition() {
|
||||
Schema schema = new Schema( null, null );
|
||||
|
|
Loading…
Reference in New Issue