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); } }
@Override protected SessionFactory buildSessionFactory(LocalSessionFactoryBuilder sfb) { sfb.buildMappings(); // For my task we need this Iterator<Table> iterator = getConfiguration().getTableMappings(); while (iterator.hasNext()){ Table table = iterator.next(); if(table.getSchema() != null && !table.getSchema().isEmpty()){ table.setSchema(schemaConfigurator.getSchemaName(table.getSchema())); } } return super.buildSessionFactory(sfb); }
foreignTable.setName(foreignTableName); foreignTable.setCatalog(getValue(element.attributeValue( "foreign-catalog"), table.getCatalog()) ); foreignTable.setSchema(getValue(element.attributeValue( "foreign-schema"), table.getSchema()) );
public Table addTable(String schema, String catalog, String name) { String key = TableNameQualifier.qualify(quote(catalog), quote(schema), quote(name)); Table table = (Table) tables.get(key); if (table == null) { table = new Table(); table.setAbstract(false); table.setName(name); table.setSchema(schema); table.setCatalog(catalog); tables.put(key, table); String qualifier = StringHelper.qualifier(key); List<Table> schemaList = qualifiers.get(qualifier); if(schemaList==null) { schemaList = new ArrayList<Table>(); qualifiers.put(qualifier, schemaList); } schemaList.add(table); } else { table.setAbstract(false); } return table; }
public Table addTable(String schema, String catalog, String name) { String key = TableNameQualifier.qualify(quote(catalog), quote(schema), quote(name)); Table table = (Table) tables.get(key); if (table == null) { table = new Table(); table.setAbstract(false); table.setName(name); table.setSchema(schema); table.setCatalog(catalog); tables.put(key, table); String qualifier = StringHelper.qualifier(key); List<Table> schemaList = qualifiers.get(qualifier); if(schemaList==null) { schemaList = new ArrayList<Table>(); qualifiers.put(qualifier, schemaList); } schemaList.add(table); } else { table.setAbstract(false); } return table; }
/** * Config table's schema by TableNamingStrategy */ private void configSchema() { TableNamingStrategy namingStrategy = null; if (getNamingStrategy() instanceof RailsNamingStrategy) { namingStrategy = ((RailsNamingStrategy) getNamingStrategy()).getTableNamingStrategy(); } if (null == namingStrategy) return; else { // Update SeqGenerator's static variable. // Because generator is init by hibernate,cannot inject namingStrategy. TableSeqGenerator.namingStrategy = namingStrategy; } if (namingStrategy.isMultiSchema()) { for (PersistentClass clazz : classes.values()) { String schema = namingStrategy.getSchema(clazz.getEntityName()); if (null != schema) clazz.getTable().setSchema(schema); } for (Collection collection : collections.values()) { final Table table = collection.getCollectionTable(); if (null == table) continue; String schema = namingStrategy.getSchema(collection.getRole()); if (null != schema) table.setSchema(schema); } } }
public Table addDenormalizedTable( String schema, String catalog, String name, boolean isAbstract, String subselect, Table includedTable) throws MappingException { String key = subselect==null ? Table.qualify(catalog, schema, name, '.') : subselect; if ( tables.containsKey(key) ) { throw new MappingException("duplicate table: " + name); } Table table = new DenormalizedTable(includedTable); table.setAbstract(isAbstract); table.setName(name); table.setSchema(schema); table.setCatalog(catalog); table.setSubselect(subselect); tables.put(key, table); return table; }
public Table addDenormalizedTable( String schema, String catalog, String name, boolean isAbstract, String subselect, Table includedTable) throws MappingException { String key = subselect==null ? Table.qualify(catalog, schema, name) : subselect; if ( tables.containsKey(key) ) { throw new DuplicateMappingException("table", name); } Table table = new DenormalizedTable(includedTable); table.setAbstract(isAbstract); table.setName(name); table.setSchema(schema); table.setCatalog(catalog); table.setSubselect(subselect); tables.put(key, table); return table; }
public Table addTable(String schema, String catalog, String name, String subselect, boolean isAbstract ) { String key = subselect==null ? Table.qualify(catalog, schema, name, '.') : subselect; Table table = (Table) tables.get(key); if (table == null) { table = new Table(); table.setAbstract(isAbstract); table.setName(name); table.setSchema(schema); table.setCatalog(catalog); table.setSubselect(subselect); tables.put(key, table); } else { if (!isAbstract) table.setAbstract(false); } return table; }
public Table addTable(String schema, String catalog, String name, String subselect, boolean isAbstract ) { String key = subselect==null ? Table.qualify(catalog, schema, name) : subselect; Table table = (Table) tables.get(key); if (table == null) { table = new Table(); table.setAbstract(isAbstract); table.setName(name); table.setSchema(schema); table.setCatalog(catalog); table.setSubselect(subselect); tables.put(key, table); } else { if (!isAbstract) table.setAbstract(false); } return table; }
element.getAttribute("foreign-catalog") : table.getCatalog()); foreignTable.setSchema( element.hasAttribute("foreign-schema") ? element.getAttribute("foreign-schema") :
public Table addDenormalizedTable( String schema, String catalog, String name, boolean isAbstract, String subselect, Table includedTable) throws DuplicateMappingException { name = getObjectNameNormalizer().normalizeIdentifierQuoting( name ); schema = getObjectNameNormalizer().normalizeIdentifierQuoting( schema ); catalog = getObjectNameNormalizer().normalizeIdentifierQuoting( catalog ); String key = subselect == null ? Table.qualify(catalog, schema, name) : subselect; if ( tables.containsKey( key ) ) { throw new DuplicateMappingException( "table", name ); } Table table = new DenormalizedTable( includedTable ); table.setAbstract( isAbstract ); table.setName( name ); table.setSchema( schema ); table.setCatalog( catalog ); table.setSubselect( subselect ); tables.put( key, table ); return table; }
public Table addDenormalizedTable( String schema, String catalog, String name, boolean isAbstract, String subselect, Table includedTable) throws DuplicateMappingException { name = getObjectNameNormalizer().normalizeIdentifierQuoting( name ); schema = getObjectNameNormalizer().normalizeIdentifierQuoting( schema ); catalog = getObjectNameNormalizer().normalizeIdentifierQuoting( catalog ); String key = subselect == null ? Table.qualify(catalog, schema, name) : subselect; if ( tables.containsKey( key ) ) { throw new DuplicateMappingException( "table", name ); } Table table = new DenormalizedTable( includedTable ); table.setAbstract( isAbstract ); table.setName( name ); table.setSchema( schema ); table.setCatalog( catalog ); table.setSubselect( subselect ); tables.put( key, table ); return table; }
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")); } }
public Table addTable( String schema, String catalog, String name, String subselect, boolean isAbstract) { name = getObjectNameNormalizer().normalizeIdentifierQuoting( name ); schema = getObjectNameNormalizer().normalizeIdentifierQuoting( schema ); catalog = getObjectNameNormalizer().normalizeIdentifierQuoting( catalog ); String key = subselect == null ? Table.qualify( catalog, schema, name ) : subselect; Table table = tables.get( key ); if ( table == null ) { table = new Table(); table.setAbstract( isAbstract ); table.setName( name ); table.setSchema( schema ); table.setCatalog( catalog ); table.setSubselect( subselect ); tables.put( key, table ); } else { if ( !isAbstract ) { table.setAbstract( false ); } } return table; }
public Table addTable( String schema, String catalog, String name, String subselect, boolean isAbstract) { name = getObjectNameNormalizer().normalizeIdentifierQuoting( name ); schema = getObjectNameNormalizer().normalizeIdentifierQuoting( schema ); catalog = getObjectNameNormalizer().normalizeIdentifierQuoting( catalog ); String key = subselect == null ? Table.qualify( catalog, schema, name ) : subselect; Table table = tables.get( key ); if ( table == null ) { table = new Table(); table.setAbstract( isAbstract ); table.setName( name ); table.setSchema( schema ); table.setCatalog( catalog ); table.setSubselect( subselect ); tables.put( key, table ); } else { if ( !isAbstract ) { table.setAbstract( false ); } } return table; }
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; }
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; }