HHH-7998 - Add TypeContributions contract

Conflicts:
	hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
	hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java
	hibernate-core/src/main/java/org/hibernate/metamodel/spi/TypeContributor.java
This commit is contained in:
Steve Ebersole 2013-04-30 10:36:38 -04:00 committed by Brett Meyer
parent 459c061eb6
commit 06fb9e70db
3 changed files with 89 additions and 2 deletions

View File

@ -39,8 +39,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
@ -79,7 +77,9 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.io.StreamCopier;
import org.hibernate.mapping.Column;
import org.hibernate.metamodel.spi.TypeContributions;
import org.hibernate.persister.entity.Lockable;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.ANSICaseFragment;
import org.hibernate.sql.ANSIJoinFragment;
import org.hibernate.sql.CaseFragment;
@ -88,6 +88,7 @@ import org.hibernate.sql.JoinFragment;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.sql.ClobTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
import org.jboss.logging.Logger;
/**
* Represents a dialect of SQL implemented by a particular RDBMS. Subclasses implement Hibernate compatibility
@ -282,6 +283,10 @@ public abstract class Dialect implements ConversionContext {
// database type mapping support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
// by default, nothing to do
}
/**
* Get the name of the database type associated with the given
* {@link java.sql.Types} typecode.

View File

@ -0,0 +1,41 @@
/*
* 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;
import org.hibernate.type.BasicType;
import org.hibernate.usertype.CompositeUserType;
import org.hibernate.usertype.UserType;
/**
* Defines the target contributing types, whether via dialects or {@link TypeContributor}
*
* @author Steve Ebersole
*/
public interface TypeContributions {
public void contributeType(BasicType type);
public void contributeType(UserType type, String[] keys);
public void contributeType(CompositeUserType type, String[] keys);
}

View File

@ -0,0 +1,41 @@
/*
* 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;
import org.hibernate.service.ServiceRegistry;
/**
* Contract for contributing types.
*
* @author Steve Ebersole
*/
public interface TypeContributor {
/**
* Contribute types
*
* @param typeContributions The callback for adding contributed types
* @param serviceRegistry The service registry
*/
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry);
}