From af2d642cf6540d7fc533911c17f7754a89a121ac Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 25 Jan 2016 10:18:27 -0600 Subject: [PATCH] HHH-9876 - Ability to filter objects from Database for schema tooling --- .../schema/internal/DefaultSchemaFilter.java | 9 ++++ .../internal/DefaultSchemaFilterProvider.java | 11 ++++- .../tool/schema/spi/SchemaFilter.java | 45 ++++++++++++++++--- .../tool/schema/spi/SchemaFilterProvider.java | 6 +++ 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/DefaultSchemaFilter.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/DefaultSchemaFilter.java index e6f166ee14..b748effd88 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/DefaultSchemaFilter.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/DefaultSchemaFilter.java @@ -1,3 +1,9 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ package org.hibernate.tool.schema.internal; import org.hibernate.boot.model.relational.Namespace; @@ -5,6 +11,9 @@ import org.hibernate.boot.model.relational.Sequence; import org.hibernate.mapping.Table; import org.hibernate.tool.schema.spi.SchemaFilter; +/** + * Default implementation of the SchemaFilter contract, which is to just include everything. + */ public class DefaultSchemaFilter implements SchemaFilter { public static final DefaultSchemaFilter INSTANCE = new DefaultSchemaFilter(); diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/DefaultSchemaFilterProvider.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/DefaultSchemaFilterProvider.java index fbb0473c86..a203136709 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/DefaultSchemaFilterProvider.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/DefaultSchemaFilterProvider.java @@ -1,10 +1,19 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ package org.hibernate.tool.schema.internal; import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaFilterProvider; +/** + * Default implementation of the SchemaFilterProvider contract, which returns + * {@link DefaultSchemaFilter} for all filters. + */ public class DefaultSchemaFilterProvider implements SchemaFilterProvider { - public static final DefaultSchemaFilterProvider INSTANCE = new DefaultSchemaFilterProvider(); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaFilter.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaFilter.java index ae70970f30..d32197ba40 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaFilter.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaFilter.java @@ -1,15 +1,50 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ package org.hibernate.tool.schema.spi; import org.hibernate.boot.model.relational.Namespace; import org.hibernate.boot.model.relational.Sequence; import org.hibernate.mapping.Table; +/** + * Defines a filter for Hibernate's schema tooling. + */ public interface SchemaFilter { + /** + * Should the given namespace (catalog+schema) be included? If {@code true}, the + * namespace will be further processed; if {@code false}, processing will skip this + * namespace. + * + * @param namespace The namespace to check for inclusion. + * + * @return {@code true} to include the namespace; {@code false} otherwise + */ + boolean includeNamespace(Namespace namespace); - boolean includeNamespace( Namespace namespace ); - - boolean includeTable( Table table ); + /** + * Should the given table be included? If {@code true}, the + * table will be further processed; if {@code false}, processing will skip this + * table. + * + * @param table The table to check for inclusion + * + * @return {@code true} to include the table; {@code false} otherwise + */ + boolean includeTable(Table table); + + /** + * Should the given sequence be included? If {@code true}, the + * sequence will be further processed; if {@code false}, processing will skip this + * sequence. + * + * @param sequence The sequence to check for inclusion + * + * @return {@code true} to include the sequence; {@code false} otherwise + */ + boolean includeSequence(Sequence sequence); - boolean includeSequence( Sequence sequence ); - } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaFilterProvider.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaFilterProvider.java index dfc6059ff2..f25cec1225 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaFilterProvider.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaFilterProvider.java @@ -1,3 +1,9 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ package org.hibernate.tool.schema.spi; /**