Package org.hibernate.cfg.reveng

Examples of org.hibernate.cfg.reveng.SchemaSelection


    // BIG HACK - should probably utilize the table cache before going to the jdbcreader :(
    if(key instanceof String) {
      String[] strings = StringHelper.split(".", (String) key);
      if(strings.length==1) {
        tableSelector.clearSchemaSelections();
        tableSelector.addSchemaSelection( new SchemaSelection(null,null, strings[0]) );
        List list = reader.readDatabaseSchema( dbc, null, null );
        return !list.isEmpty();
      } else if(strings.length==3) {
        tableSelector.clearSchemaSelections();
        tableSelector.addSchemaSelection( new SchemaSelection(strings[0],strings[1], strings[2]) );
        List list = reader.readDatabaseSchema( dbc, null, null );
        return !list.isEmpty();
      } else if (strings.length==2) {
        tableSelector.clearSchemaSelections();
        tableSelector.addSchemaSelection( new SchemaSelection(null,strings[0], strings[1]) );
        List list = reader.readDatabaseSchema( dbc, null, null );
        return !list.isEmpty();
      }
    }
    return false;
View Full Code Here


    }
  }

  private void setSchemaSelection(Table table) {
    tableSelector.clearSchemaSelections();
    tableSelector.addSchemaSelection( new SchemaSelection( table
        .getCatalog(), table.getSchema(), table.getName() ) );

  }
View Full Code Here

  public void testReadOnlySpecificSchema() {
   
    JDBCMetaDataConfiguration configuration = new JDBCMetaDataConfiguration();
   
    OverrideRepository or = new OverrideRepository();
    or.addSchemaSelection(new SchemaSelection(null, SCHEMA));
    configuration.setReverseEngineeringStrategy(or.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()));
    configuration.readFromJDBC();
   
    List tables = getTables(configuration);
   
View Full Code Here

  public void testReadOnlySpecificSchema() {
   
    JDBCMetaDataConfiguration configuration = new JDBCMetaDataConfiguration();
   
    OverrideRepository or = new OverrideRepository();
    or.addSchemaSelection(new SchemaSelection(null, "OVRTEST"));
    configuration.setReverseEngineeringStrategy(or.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()));
    configuration.readFromJDBC();
   
    List tables = getTables(configuration);
   
View Full Code Here

  public void testOverlapping() {
   
    JDBCMetaDataConfiguration configuration = new JDBCMetaDataConfiguration();
   
    OverrideRepository or = new OverrideRepository();
    or.addSchemaSelection(new SchemaSelection(null, "OVRTEST"));
    or.addSchemaSelection(new SchemaSelection(null, null));
    configuration.setReverseEngineeringStrategy(or.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()));
    configuration.readFromJDBC();
   
    Set tables = new HashSet();
    Iterator iter = configuration.getTableMappings();
View Full Code Here

    TableSelectorStrategy tss = new TableSelectorStrategy(new DefaultReverseEngineeringStrategy());
    MockedMetaDataDialect mockedMetaDataDialect = new MockedMetaDataDialect();
    JDBCReader reader = JDBCReaderFactory.newJDBCReader( buildSettings, tss, mockedMetaDataDialect, serviceRegistry);
   
    tss.addSchemaSelection( new SchemaSelection(null,null, "CHILD") );
   
    DatabaseCollector dc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
    reader.readDatabaseSchema( dc, null, null );
   
    assertEquals(mockedMetaDataDialect.gottenTables.size(),1);
    assertEquals(mockedMetaDataDialect.gottenTables.get(0),"CHILD");
   
    Iterator iterator = dc.iterateTables();
    Table firstChild = (Table) iterator.next();
    assertEquals(firstChild.getName(), "CHILD");
    assertFalse(iterator.hasNext());
   
    assertFalse("should not record foreignkey to table it doesn't know about yet",firstChild.getForeignKeyIterator().hasNext());
   
    tss.clearSchemaSelections();
    tss.addSchemaSelection( new SchemaSelection(null, null, "MASTER") );
   
    mockedMetaDataDialect.gottenTables.clear();
    reader.readDatabaseSchema( dc, null, null );
   
    assertEquals(mockedMetaDataDialect.gottenTables.size(),1);
View Full Code Here

    List schemaSelectors = repository.getSchemaSelections();
   
    assertNotNull(schemaSelectors);
    assertEquals(4,schemaSelectors.size());
   
    SchemaSelection ss;
    ss = (SchemaSelection) schemaSelectors.get(0);
    assertEquals(null,ss.getMatchCatalog());
    assertEquals(null,ss.getMatchSchema());
    assertEquals(null,ss.getMatchTable());
   
    ss = (SchemaSelection) schemaSelectors.get(1);
    assertEquals(null,ss.getMatchCatalog());
    assertEquals("OVRTEST",ss.getMatchSchema());
    assertEquals(null,ss.getMatchTable());
   
    ss = (SchemaSelection) schemaSelectors.get(2);
    assertEquals("UBERCATALOG",ss.getMatchCatalog());
    assertEquals("OVRTEST",ss.getMatchSchema());
    assertEquals(null,ss.getMatchTable());
   
    ss = (SchemaSelection) schemaSelectors.get(3);
    assertEquals("PUBLIC.*",ss.getMatchCatalog());
    assertEquals("OVRTEST",ss.getMatchSchema());
    assertEquals(".*",ss.getMatchTable());
   
    JDBCMetaDataConfiguration configuration = new JDBCMetaDataConfiguration();
   
    OverrideRepository ox = new OverrideRepository();
    ox.addSchemaSelection(new SchemaSelection(null, null, "DUMMY.*"));
    configuration.setReverseEngineeringStrategy(ox.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()));
    configuration.readFromJDBC();
   
    Iterator tableMappings = configuration.getTableMappings();
    Table t = (Table) tableMappings.next();
View Full Code Here

   
    super.configure(configuration);
     DefaultReverseEngineeringStrategy c = new DefaultReverseEngineeringStrategy() {
       public List getSchemaSelections() {
         List selections = new ArrayList();
         selections.add(new SchemaSelection(null, "PUBLIC"));
         selections.add(new SchemaSelection(null, "otherschema"));
         selections.add(new SchemaSelection(null, "thirdschema"));
        return selections;
      }
     };
              
       configuration.setReverseEngineeringStrategy(c);
View Full Code Here

    // BIG HACK - should probably utilize the table cache before going to the jdbcreader :(
    if(key instanceof String) {
      String[] strings = StringHelper.split(".", (String) key);
      if(strings.length==1) {
        tableSelector.clearSchemaSelections();
        tableSelector.addSchemaSelection( new SchemaSelection(null,null, strings[0]) );
        List list = reader.readDatabaseSchema( dbc, null, null );
        return !list.isEmpty();
      } else if(strings.length==3) {
        tableSelector.clearSchemaSelections();
        tableSelector.addSchemaSelection( new SchemaSelection(strings[0],strings[1], strings[2]) );
        List list = reader.readDatabaseSchema( dbc, null, null );
        return !list.isEmpty();
      } else if (strings.length==2) {
        tableSelector.clearSchemaSelections();
        tableSelector.addSchemaSelection( new SchemaSelection(null,strings[0], strings[1]) );
        List list = reader.readDatabaseSchema( dbc, null, null );
        return !list.isEmpty();
      }
    }
    return false;
View Full Code Here

    }
  }

  private void setSchemaSelection(Table table) {
    tableSelector.clearSchemaSelections();
    tableSelector.addSchemaSelection( new SchemaSelection( table
        .getCatalog(), table.getSchema(), table.getName() ) );

  }
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.reveng.SchemaSelection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.