From b847b0598aba30964ce9860022aa4d20546174c6 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 8 Feb 2012 13:11:20 -0600 Subject: [PATCH] HHH-7038 - Define sources for filters, filter-defs, type-defs, fetch-profiles --- .../spi/source/ConfigurationValueSource.java | 45 ++++++++++++ .../spi/source/FetchProfileSource.java | 73 +++++++++++++++++++ .../metamodel/spi/source/FilterDefSource.java | 60 +++++++++++++++ .../spi/source/FilterParameterSource.java | 45 ++++++++++++ .../metamodel/spi/source/FilterSource.java | 60 +++++++++++++++ .../spi/source/TypeDescriptorSource.java | 37 ++++++++++ 6 files changed, 320 insertions(+) create mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/ConfigurationValueSource.java create mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FetchProfileSource.java create mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefSource.java create mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterParameterSource.java create mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterSource.java create mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/TypeDescriptorSource.java diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/ConfigurationValueSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/ConfigurationValueSource.java new file mode 100644 index 0000000000..fc2c053a9c --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/ConfigurationValueSource.java @@ -0,0 +1,45 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2012, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.metamodel.spi.source; + +/** + * Defines a source of configuration value. + * + * @author Steve Ebersole + */ +public interface ConfigurationValueSource { + /** + * Get the configuration name. + * + * @return The configuration name + */ + public String getName(); + + /** + * Get the configuration value + * + * @return The configuration value. + */ + public String getValue(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FetchProfileSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FetchProfileSource.java new file mode 100644 index 0000000000..dc79904ce2 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FetchProfileSource.java @@ -0,0 +1,73 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2012, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.metamodel.spi.source; + +import org.hibernate.annotations.FetchMode; + +/** + * Defines a source of fetch profile information + * + * @author Steve Ebersole + */ +public interface FetchProfileSource { + /** + * Defines a source of an association fetch information within a fetch profile + */ + public static interface AssociationOverrideSource { + /** + * Retrieve the name of the entity containing the association. + * + * @return The entity name. + */ + public String getEntityName(); + + /** + * Retrieve the name of the association attribute on the entity. + * + * @return The attribute name + */ + public String getAttributeName(); + + /** + * Retrieve the fetch mode to be applied to the association as part of this profile. + * + * @return the fetch mode. + */ + public FetchMode getFetchMode(); + } + + /** + * Retrieve the name of the profile. + * + * @return The profile name. + */ + public String getName(); + + /** + * Retrieve the association fetching overrides associated with this profile. + * + * @return The association fetching overrides + */ + public Iterable getAssociationOverrides(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefSource.java new file mode 100644 index 0000000000..69815680e3 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefSource.java @@ -0,0 +1,60 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2012, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.metamodel.spi.source; + +/** + * Describe the source of filer def information. Generally either {@code } or + * {@link org.hibernate.annotations.FilterDef @FilterDef} + * + * @author Steve Ebersole + */ +public interface FilterDefSource { + /** + * Retrieve the name of the filter. Would match the related {@link FilterSource#getName} + * + * @return The filter name + * + * @see FilterSource#getName + */ + public String getName(); + + /** + * Retrieve the condition specified as part of the def. Defines the condition to use + * in related filters when {@link FilterSource#getCondition} is null. + * + * @return The "default" condition for associated filters. + * + * @see FilterSource#getCondition + */ + public String getCondition(); + + /** + * Retrieve parameter sources associated with this filer def. + * + * @return The parameter sources. Can be null. + * + * @see FilterSource#getParameterSources() + */ + public Iterable getParameterSources(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterParameterSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterParameterSource.java new file mode 100644 index 0000000000..3c2555fc82 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterParameterSource.java @@ -0,0 +1,45 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2012, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.metamodel.spi.source; + +/** + * Describes the source of filter parameter information + * + * @author Steve Ebersole + */ +public interface FilterParameterSource { + /** + * Retrieve the name of the parameter being described. + * + * @return The name + */ + public String getParameterName(); + + /** + * The Hibernate type name that can be used to handle bound parameter values. + * + * @return the type + */ + public String getParameterValueTyeName(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterSource.java new file mode 100644 index 0000000000..6f7b959d38 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterSource.java @@ -0,0 +1,60 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2012, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.metamodel.spi.source; + +/** + * Defines the source of filter information. May have an associated {@link FilterDefSource}. + * Relates to both {@code } and {@link org.hibernate.annotations.Filter @Filter} + * + * @author Steve Ebersole + */ +public interface FilterSource { + /** + * Get the name of the filter being described. + * + * @return The name. + */ + public String getName(); + + /** + * Get the condition associated with the filter. Can be {@code null} in the case of a filter described + * further by a "filter def" which contains the condition text. + * + * @return The condition defined on the filter. + * + * @see {@link org.hibernate.metamodel.spi.source.FilterDefSource#getCondition()} + */ + public String getCondition(); + + /** + * Retrieves the defined sources of parameter information pertaining to this filer. + *

+ * Will be merged with parameter sources associated with matching "filter def" + * + * @return The parameter sources defined on the filter. + * + * @see {@link org.hibernate.metamodel.spi.source.FilterDefSource#getParameterSources()} + */ + public Iterable getParameterSources(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/TypeDescriptorSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/TypeDescriptorSource.java new file mode 100644 index 0000000000..5b8aba1c5d --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/TypeDescriptorSource.java @@ -0,0 +1,37 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2012, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.metamodel.spi.source; + +/** + * Describes the source of a custom type description. For example, {@code } or + * {@link org.hibernate.annotations.TypeDef @TypeDef} + * + * @author Steve Ebersole + */ +public interface TypeDescriptorSource { + public String getName(); + public String getTypeImplementationClassName(); + public Iterable getRegistrationKeys(); + public Iterable getConfigurationValueSources(); +}