Package org.hibernate.cfg.reveng

Examples of org.hibernate.cfg.reveng.JDBCReader$ForeignKeysInfo


  public DatabaseCollector readDatabaseSchema(String catalog, String schema) throws SQLException {
       // use default from settings if nothing else specified.
       catalog = catalog!=null ? catalog : settings.getDefaultCatalogName();
       schema = schema!=null ? schema : settings.getDefaultSchemaName();

       JDBCReader reader = JDBCReaderFactory.newJDBCReader(cfg.getProperties(),settings,revengStrategy);
       DatabaseCollector dbs = new MappingsDatabaseCollector(mappings, reader.getMetaDataDialect());
       reader.readDatabaseSchema(dbs, catalog, schema);
       return dbs;
  }
View Full Code Here


  public DatabaseCollector readDatabaseSchema(String catalog, String schema) throws SQLException {
       // use default from settings if nothing else specified.
       catalog = catalog!=null ? catalog : settings.getDefaultCatalogName();
       schema = schema!=null ? schema : settings.getDefaultSchemaName();

       JDBCReader reader = JDBCReaderFactory.newJDBCReader(cfg.getProperties(),settings,revengStrategy);
       DatabaseCollector dbs = new MappingsDatabaseCollector(mappings, reader.getMetaDataDialect());
       reader.readDatabaseSchema(dbs, catalog, schema);
       return dbs;
  }
View Full Code Here

    return newJDBCReader( settings, revengStrategy, mdd );
  }

  public static JDBCReader newJDBCReader(Settings settings, ReverseEngineeringStrategy revengStrategy, MetaDataDialect mdd) { 
    return new JDBCReader( mdd, settings.getConnectionProvider(), settings
        .getSQLExceptionConverter(), settings.getDefaultCatalogName(), settings.getDefaultSchemaName(), revengStrategy );
  }
View Full Code Here

    ServiceRegistry serviceRegistry = builder.build();
    Settings buildSettings = cfg.buildSettings(serviceRegistry);
       
    MetaDataDialect realMetaData = JDBCReaderFactory.newMetaDataDialect( serviceRegistry.getService(JdbcServices.class).getDialect(), cfg.getProperties() );
   
    JDBCReader reader = JDBCReaderFactory.newJDBCReader( buildSettings, new DefaultReverseEngineeringStrategy(), realMetaData, serviceRegistry );
   
    DatabaseCollector dc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
    reader.readDatabaseSchema( dc, null, SCHEMA );
   
    assertNotNull("The table should be found", dc.getTable(SCHEMA, null, TABLE1));
    assertNotNull("The table should be found", dc.getTable(SCHEMA, null, TABLE2));
    assertNull("Quoted names should not return the table", dc.getTable(quote(SCHEMA), null, QTABLE1));
    assertNull("Quoted names should not return the table", dc.getTable(quote(SCHEMA), null, QTABLE2));
View Full Code Here

    Settings buildSettings = cfg.buildSettings(serviceRegistry);

    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);
    assertEquals(mockedMetaDataDialect.gottenTables.get(0),"MASTER");
   
   
    iterator = dc.iterateTables();
    assertNotNull(iterator.next());
    assertNotNull(iterator.next());
    assertFalse(iterator.hasNext());
   
    Table table = dc.getTable( null, null, "CHILD" );
    assertSame( firstChild, table );
   
    assertHasNext("should have recorded one foreignkey to child table", 1, firstChild.getForeignKeyIterator() );   
   
   
    tss.clearSchemaSelections();   
    reader.readDatabaseSchema( dc, null, null );
   
    Table finalMaster = dc.getTable( null, null, "MASTER" );
   
    assertSame(firstChild, dc.getTable( null, null, "CHILD" ));
    assertHasNext( 1, firstChild.getForeignKeyIterator() );
View Full Code Here

    MetaDataDialect realMetaData = JDBCReaderFactory.newMetaDataDialect( serviceRegistry.getService(JdbcServices.class).getDialect(), cfg.getProperties() );
   
    MockedMetaDataDialect mock = new MockedMetaDataDialect(realMetaData);
    CachedMetaDataDialect dialect = new CachedMetaDataDialect(mock);
   
    JDBCReader reader = JDBCReaderFactory.newJDBCReader( buildSettings, new DefaultReverseEngineeringStrategy(), dialect, serviceRegistry );
   
    DatabaseCollector dc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
    reader.readDatabaseSchema( dc, null, null );

    validate( dc );   
   
    mock.setFailOnDelegateAccess(true);
   
    reader = JDBCReaderFactory.newJDBCReader( buildSettings, new DefaultReverseEngineeringStrategy(), dialect, serviceRegistry );
   
    dc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
    reader.readDatabaseSchema( dc, null, null );

    validate(dc);
   
   
   
View Full Code Here

  }

  public static JDBCReader newJDBCReader(Settings settings, ReverseEngineeringStrategy revengStrategy, MetaDataDialect mdd,
      ServiceRegistry serviceRegistry) {
    JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
    return new JDBCReader( mdd, jdbcServices.getConnectionProvider(), jdbcServices.getSqlExceptionHelper()
        .getSqlExceptionConverter(), settings.getDefaultCatalogName(), settings.getDefaultSchemaName(), revengStrategy );
  }
View Full Code Here

  public DatabaseCollector readDatabaseSchema(String catalog, String schema) throws SQLException {
       // use default from settings if nothing else specified.
       catalog = catalog!=null ? catalog : settings.getDefaultCatalogName();
       schema = schema!=null ? schema : settings.getDefaultSchemaName();

       JDBCReader reader = JDBCReaderFactory.newJDBCReader(cfg.getProperties(),settings,revengStrategy, cfg.getServiceRegistry());
       DatabaseCollector dbs = new MappingsDatabaseCollector(mappings, reader.getMetaDataDialect());
       reader.readDatabaseSchema(dbs, catalog, schema);
       return dbs;
  }
View Full Code Here

  public DatabaseCollector readDatabaseSchema(String catalog, String schema) throws SQLException {
       // use default from settings if nothing else specified.
       catalog = catalog!=null ? catalog : settings.getDefaultCatalogName();
       schema = schema!=null ? schema : settings.getDefaultSchemaName();

       JDBCReader reader = JDBCReaderFactory.newJDBCReader(cfg.getProperties(),settings,revengStrategy, cfg.getServiceRegistry());
       DatabaseCollector dbs = new MappingsDatabaseCollector(mappings, reader.getMetaDataDialect());
       reader.readDatabaseSchema(dbs, catalog, schema);
       return dbs;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.reveng.JDBCReader$ForeignKeysInfo

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.