Skip to content

Commit aecd5a4

Browse files
sebersolebrmeyer
authored andcommitted
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
1 parent 2d0a757 commit aecd5a4

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@
7777
import org.hibernate.internal.util.collections.ArrayHelper;
7878
import org.hibernate.internal.util.io.StreamCopier;
7979
import org.hibernate.mapping.Column;
80+
import org.hibernate.metamodel.spi.TypeContributions;
8081
import org.hibernate.persister.entity.Lockable;
82+
import org.hibernate.service.ServiceRegistry;
8183
import org.hibernate.sql.ANSICaseFragment;
8284
import org.hibernate.sql.ANSIJoinFragment;
8385
import org.hibernate.sql.CaseFragment;
@@ -272,6 +274,10 @@ public String toString() {
272274

273275
// database type mapping support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274276

277+
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
278+
// by default, nothing to do
279+
}
280+
275281
/**
276282
* Get the name of the database type associated with the given
277283
* {@link java.sql.Types} typecode.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
package org.hibernate.metamodel.spi;
25+
26+
import org.hibernate.type.BasicType;
27+
import org.hibernate.usertype.CompositeUserType;
28+
import org.hibernate.usertype.UserType;
29+
30+
/**
31+
* Defines the target contributing types, whether via dialects or {@link TypeContributor}
32+
*
33+
* @author Steve Ebersole
34+
*/
35+
public interface TypeContributions {
36+
public void contributeType(BasicType type);
37+
38+
public void contributeType(UserType type, String[] keys);
39+
40+
public void contributeType(CompositeUserType type, String[] keys);
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
package org.hibernate.metamodel.spi;
25+
26+
import org.hibernate.service.ServiceRegistry;
27+
28+
/**
29+
* Contract for contributing types.
30+
*
31+
* @author Steve Ebersole
32+
*/
33+
public interface TypeContributor {
34+
/**
35+
* Contribute types
36+
*
37+
* @param typeContributions The callback for adding contributed types
38+
* @param serviceRegistry The service registry
39+
*/
40+
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry);
41+
}

0 commit comments

Comments
 (0)