@Override protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException { if (!snapshot.getSnapshotControl().shouldInclude(Index.class)) { return; } if (foundObject instanceof Table) { Table table = (Table) foundObject; org.hibernate.mapping.Table hibernateTable = findHibernateTable(table, snapshot); if (hibernateTable == null) { return; } Iterator indexIterator = hibernateTable.getIndexIterator(); while (indexIterator.hasNext()) { org.hibernate.mapping.Index hibernateIndex = (org.hibernate.mapping.Index) indexIterator.next(); Index index = new Index(); index.setTable(table); index.setName(hibernateIndex.getName()); Iterator columnIterator = hibernateIndex.getColumnIterator(); while (columnIterator.hasNext()) { org.hibernate.mapping.Column hibernateColumn = (org.hibernate.mapping.Column) columnIterator.next(); index.getColumns().add(new Column(hibernateColumn.getName()).setRelation(table)); } LOG.info("Found index " + index.getName()); table.getIndexes().add(index); } } }
@Override protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException { if (!snapshot.getSnapshotControl().shouldInclude(Table.class)) { return; } if (foundObject instanceof Schema) { Schema schema = (Schema) foundObject; HibernateDatabase database = (HibernateDatabase) snapshot.getDatabase(); Configuration cfg = database.getConfiguration(); Iterator<org.hibernate.mapping.Table> tableMappings = cfg.getTableMappings(); while (tableMappings.hasNext()) { org.hibernate.mapping.Table hibernateTable = tableMappings.next(); if (hibernateTable.isPhysicalTable()) { Table table = new Table().setName(hibernateTable.getName()); table.setSchema(schema); LOG.info("Found table " + table.getName()); schema.addDatabaseObject(table); } } } } }
@Override protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException { if (!snapshot.getSnapshotControl().shouldInclude(Sequence.class)) { return;
@Override protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException { if (!snapshot.getSnapshotControl().shouldInclude(PrimaryKey.class)) { return;
@Override protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException { if (!snapshot.getSnapshotControl().shouldInclude(UniqueConstraint.class)) { return;
@Override protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException { if (!snapshot.getSnapshotControl().shouldInclude(Table.class)) { return;
@Override protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException { if (!snapshot.getSnapshotControl().shouldInclude(ForeignKey.class)) { return;