/** * Creates a mapping Table instance. * * @param logicalTableName The logical table name * * @return the created table. */ public Table createTable(Identifier logicalTableName, boolean isAbstract) { final Table existing = tables.get( logicalTableName ); if ( existing != null ) { return existing; } final Identifier physicalTableName = physicalNamingStrategy.toPhysicalTableName( logicalTableName, jdbcEnvironment ); Table table = new Table( this, physicalTableName, isAbstract ); tables.put( logicalTableName, table ); return table; }
foreignKey.setName( "objectId2id_1" ); // Make sure the match is not successful based on key name foreignKey.addColumn( new Column( "id" ) ); foreignKey.setReferencedTable( new Table( "table2" ) );
foreignKey.setName( "objectId2id_1" ); // Make sure the match is not successful based on key name foreignKey.addColumn( new Column( "id" ) ); foreignKey.setReferencedTable( new Table( "table2" ) );
jdbcEnvironment.getDialect() ); final Table idTable = new Table(); idTable.setName( idTableName ); idTable.setComment( "Used to hold id values for the " + entityBinding.getEntityName() + " entity" );
foreignKey.setName( "objectId2id" ); foreignKey.addColumn( new Column( "id" ) ); foreignKey.setReferencedTable( new Table( "table2" ) );
foreignKey.setName( "objectId2id_1" ); foreignKey.addColumn( new Column( "id" ) ); foreignKey.setReferencedTable( new Table( "table2" ) );
return new Table( namespace, logicalName, subselectFragment, isAbstract );
logicalTableName = database.toIdentifier( inLineViewSource.getLogicalName() ); if ( denormalizedSuperTable == null ) { table = new Table( namespace, subselect, isAbstract );
collectionTable = new Table( namespace, ( (InLineViewSource) tableSpecSource ).getSelectStatement(),
secondaryTable = new Table( namespace, inLineViewSource.getSelectStatement(),
@Test public void testProperCallbacks() { final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( serviceRegistry ) .buildMetadata(); final Table tbl = new Table(); final RootClass rootClass = new RootClass( metadataBuildingContext ); ValueVisitor vv = new ValueVisitorValidator(); MetadataBuildingContextTestingImpl metadataBuildingContext = new MetadataBuildingContextTestingImpl(); new Any( metadataBuildingContext, tbl ).accept( vv ); new Array( metadataBuildingContext, rootClass ).accept( vv ); new Bag( metadataBuildingContext, rootClass ).accept( vv ); new Component( metadataBuildingContext, rootClass ).accept( vv ); new DependantValue( metadataBuildingContext, tbl, null ).accept( vv ); new IdentifierBag( metadataBuildingContext, rootClass ).accept( vv ); new List( metadataBuildingContext, rootClass ).accept( vv ); new ManyToOne( metadataBuildingContext, tbl ).accept( vv ); new Map( metadataBuildingContext, rootClass ).accept( vv ); new OneToMany( metadataBuildingContext, rootClass ).accept( vv ); new OneToOne( metadataBuildingContext, tbl, rootClass ).accept( vv ); new PrimitiveArray( metadataBuildingContext, rootClass ).accept( vv ); new Set( metadataBuildingContext, rootClass ).accept( vv ); new SimpleValue( metadataBuildingContext ).accept( vv ); }
/** * Creates a mapping Table instance. * * @param logicalTableName The logical table name * * @return the created table. */ public MappedTable createTable(Identifier logicalTableName, boolean isAbstract) { final MappedTable existing = tables.get( logicalTableName ); if ( existing != null ) { return existing; } Table table = new Table( this, logicalTableName, isAbstract ); tables.put( logicalTableName, table ); return table; }
private static void bindTables(List<?> tables, OverrideRepository repository) { Iterator<?> iterator = tables.iterator(); while ( iterator.hasNext() ) { Element element = (Element) iterator.next(); Table table = new Table(); table.setCatalog( element.attributeValue("catalog") ); table.setSchema( element.attributeValue("schema") ); table.setName( element.attributeValue("name") ); String wantedClassName = element.attributeValue("class"); Element primaryKey = element.element("primary-key"); bindPrimaryKey(primaryKey, table, repository); List<?> columns = element.elements("column"); bindColumns(columns, table, repository); List<?> foreignKeys = element.elements("foreign-key"); bindForeignKeys(foreignKeys, table, repository); bindMetaAttributes(element, table, repository); repository.addTable(table,wantedClassName); } }
public void prepareTemporaryTables(Mapping mapping, Dialect dialect) { if ( dialect.supportsTemporaryTables() ) { temporaryIdTableName = dialect.generateTemporaryTableName( getTable().getName() ); Table table = new Table(); table.setName( temporaryIdTableName ); Iterator itr = getTable().getPrimaryKey().getColumnIterator(); while( itr.hasNext() ) { Column column = (Column) itr.next(); table.addColumn( (Column) column.clone() ); } temporaryIdTableDDL = table.sqlTemporaryTableCreateString( dialect, mapping ); } }
public void prepareTemporaryTables(Mapping mapping, Dialect dialect) { if ( dialect.supportsTemporaryTables() ) { temporaryIdTableName = dialect.generateTemporaryTableName( getTable().getName() ); Table table = new Table(); table.setName( temporaryIdTableName ); Iterator itr = getTable().getPrimaryKey().getColumnIterator(); while( itr.hasNext() ) { Column column = (Column) itr.next(); table.addColumn( (Column) column.clone() ); } temporaryIdTableDDL = table.sqlTemporaryTableCreateString( dialect, mapping ); } }
public void prepareTemporaryTables(Mapping mapping, Dialect dialect) { if ( dialect.supportsTemporaryTables() ) { temporaryIdTableName = dialect.generateTemporaryTableName( getTable().getName() ); Table table = new Table(); table.setName( temporaryIdTableName ); Iterator itr = getTable().getPrimaryKey().getColumnIterator(); while( itr.hasNext() ) { Column column = (Column) itr.next(); table.addColumn( (Column) column.clone() ); } temporaryIdTableDDL = table.sqlTemporaryTableCreateString( dialect, mapping ); } }
@Override public Identifier determineForeignKeyName(final ImplicitForeignKeyNameSource source) { return toIdentifier(Constraint.generateName("FK_", new Table(source.getTableName().getText()), toColumns(source.getColumnNames())), source.getBuildingContext()); }
@Override public Identifier determineUniqueKeyName(final ImplicitUniqueKeyNameSource source) { return toIdentifier(Constraint.generateName("UK_", new Table(source.getTableName().getText()), toColumns(source.getColumnNames())), source.getBuildingContext()); } }
public boolean isTable(Object key) throws HibernateException { if(key instanceof String) { Table tbl = new Table((String)key); if ( getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null ) { return true; } else { String[] strings = StringHelper.split(".", (String) key); if(strings.length==3) { tbl = new Table(strings[2]); tbl.setCatalog(strings[0]); tbl.setSchema(strings[1]); return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null; } else if (strings.length==2) { tbl = new Table(strings[1]); tbl.setSchema(strings[0]); return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null; } } } return false; }
private static void bindTables( ArrayList<Element> tables, OverrideRepository repository) { for (Element element : tables) { Table table = new Table(); table.setCatalog(getAttribute(element, "catalog")); table.setSchema(getAttribute(element, "schema")); table.setName(getAttribute(element, "name")); ArrayList<Element> primaryKeys = getChildElements(element, "primary-key"); if (primaryKeys.size() > 0) { bindPrimaryKey(primaryKeys.get(0), table, repository); } bindColumns(getChildElements(element, "column"), table, repository); bindForeignKeys(getChildElements(element, "foreign-key"), table, repository); bindMetaAttributes(element, table, repository); repository.addTable(table, getAttribute(element, "class")); } }