@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 DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException { if (example.getSnapshotId() != null) { return example; } org.hibernate.mapping.Table hibernateTable = findHibernateTable(example, snapshot); if (hibernateTable == null) { return example; } Table table = new Table().setName(hibernateTable.getName()); LOG.info("Found table " + table.getName()); // table.setSnapshotId(SnapshotIdService.getInstance().generateId()); table.setSchema(example.getSchema()); return table; }
if (hibernateTable.isPhysicalTable()) { Table table = new Table().setName(hibernateTable.getName()); table.setSchema(schema); LOG.info("Found table " + table.getName()); schema.addDatabaseObject(snapshotObject(table, snapshot)); if (tableIdGenerator.supports(ig)) { Table idTable = tableIdGenerator.snapshot(ig); idTable.setSchema(schema); schema.addDatabaseObject(snapshotObject(idTable, snapshot)); break; if (hTable.isPhysicalTable()) { Table table = new Table().setName(hTable.getName()); table.setSchema(schema); LOG.info("Found table " + table.getName()); schema.addDatabaseObject(snapshotObject(table, snapshot));
org.hibernate.mapping.ForeignKey hibernateForeignKey = (org.hibernate.mapping.ForeignKey) fkIterator.next(); Table currentTable = new Table().setName(hibernateTable.getName()); currentTable.setSchema(hibernateTable.getCatalog(), hibernateTable.getSchema()); referencedTable.setSchema(hibernateReferencedTable.getCatalog(), hibernateReferencedTable.getSchema());
LOG.info("Found table " + table.getName()); table.setSchema(example.getSchema());