remove type parameter from BasicValueBinder

why it ever had one, I can only speculate
This commit is contained in:
Gavin King 2022-01-28 00:21:10 +01:00
parent fb1650f789
commit 77137f7407
11 changed files with 52 additions and 33 deletions

View File

@ -814,8 +814,8 @@ public class BinderHelper {
value.setLazy( lazy );
value.setCascadeDeleteEnabled( cascadeOnDelete );
final BasicValueBinder<?> discriminatorValueBinder =
new BasicValueBinder<>( BasicValueBinder.Kind.ANY_DISCRIMINATOR, context );
final BasicValueBinder discriminatorValueBinder =
new BasicValueBinder( BasicValueBinder.Kind.ANY_DISCRIMINATOR, context );
final AnnotatedColumn[] discriminatorColumns = buildColumnOrFormulaFromAnnotation(
discriminatorColumn,
@ -853,7 +853,7 @@ public class BinderHelper {
);
value.setDiscriminatorValueMappings( discriminatorValueMappings );
BasicValueBinder<?> keyValueBinder = new BasicValueBinder<>( BasicValueBinder.Kind.ANY_KEY, context );
BasicValueBinder keyValueBinder = new BasicValueBinder( BasicValueBinder.Kind.ANY_KEY, context );
assert keyColumns.length == 1;
keyColumns[0].setTable( value.getTable() );
keyValueBinder.setColumns( keyColumns );

View File

@ -16,9 +16,9 @@ import org.hibernate.mapping.PersistentClass;
* @author Sharath Reddy
*/
public class SetBasicValueTypeSecondPass implements SecondPass {
private final BasicValueBinder<?> binder;
private final BasicValueBinder binder;
public SetBasicValueTypeSecondPass(BasicValueBinder<?> val) {
public SetBasicValueTypeSecondPass(BasicValueBinder val) {
binder = val;
}

View File

@ -22,7 +22,10 @@ import org.hibernate.usertype.UserCollectionType;
* @author Anthony Patricio
*/
public class ArrayBinder extends ListBinder {
public ArrayBinder(Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver, MetadataBuildingContext buildingContext) {
public ArrayBinder(
Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver,
MetadataBuildingContext buildingContext) {
super( customTypeBeanResolver, buildingContext );
}

View File

@ -21,7 +21,10 @@ import org.hibernate.usertype.UserCollectionType;
* @author Matthew Inger
*/
public class BagBinder extends CollectionBinder {
public BagBinder(Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver, MetadataBuildingContext context) {
public BagBinder(
Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver,
MetadataBuildingContext context) {
super( customTypeBeanResolver, false, context );
}

View File

@ -97,7 +97,7 @@ import static org.hibernate.cfg.annotations.HCANNHelper.findAnnotation;
* @author Steve Ebersole
* @author Emmanuel Bernard
*/
public class BasicValueBinder<T> implements JdbcTypeIndicators {
public class BasicValueBinder implements JdbcTypeIndicators {
// todo (6.0) : In light of how we want to build Types (specifically BasicTypes) moving forward this class should undergo major changes
// see the comments in #setType
@ -163,7 +163,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
public BasicValueBinder(Kind kind, MetadataBuildingContext buildingContext) {
assert kind != null;
assert buildingContext != null;
assert buildingContext != null;
this.kind = kind;
this.buildingContext = buildingContext;

View File

@ -1785,8 +1785,8 @@ public abstract class CollectionBinder {
else {
holder.prepare(property);
final BasicValueBinder<?> elementBinder =
new BasicValueBinder<>( BasicValueBinder.Kind.COLLECTION_ELEMENT, buildingContext);
final BasicValueBinder elementBinder =
new BasicValueBinder( BasicValueBinder.Kind.COLLECTION_ELEMENT, buildingContext);
elementBinder.setReturnedClassName( collType.getName() );
if ( elementColumns == null || elementColumns.length == 0 ) {
elementColumns = new AnnotatedColumn[1];

View File

@ -109,8 +109,8 @@ public class IdBagBinder extends BagBinder {
idColumn.setNullable( false );
}
final BasicValueBinder<?> valueBinder =
new BasicValueBinder<>( BasicValueBinder.Kind.COLLECTION_ID, buildingContext );
final BasicValueBinder valueBinder =
new BasicValueBinder( BasicValueBinder.Kind.COLLECTION_ID, buildingContext );
final Table table = collection.getCollectionTable();
valueBinder.setTable( table );

View File

@ -42,7 +42,9 @@ import org.jboss.logging.Logger;
public class ListBinder extends CollectionBinder {
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, ListBinder.class.getName() );
public ListBinder(Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver, MetadataBuildingContext buildingContext) {
public ListBinder(
Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver,
MetadataBuildingContext buildingContext) {
super( customTypeBeanResolver, false, buildingContext );
}
@ -112,7 +114,7 @@ public class ListBinder extends CollectionBinder {
indexColumn.forceNotNull();
}
indexColumn.setPropertyHolder( valueHolder );
final BasicValueBinder<?> valueBinder = new BasicValueBinder<>( BasicValueBinder.Kind.LIST_INDEX, buildingContext );
final BasicValueBinder valueBinder = new BasicValueBinder( BasicValueBinder.Kind.LIST_INDEX, buildingContext );
valueBinder.setColumns( new AnnotatedColumn[] { indexColumn } );
valueBinder.setReturnedClassName( Integer.class.getName() );
valueBinder.setType( property, collType, null, null );

View File

@ -29,7 +29,6 @@ import org.hibernate.cfg.AnnotatedColumn;
import org.hibernate.cfg.AnnotatedJoinColumn;
import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.PropertyData;
import org.hibernate.cfg.PropertyHolderBuilder;
import org.hibernate.cfg.PropertyPreloadedData;
import org.hibernate.cfg.SecondPass;
import org.hibernate.engine.jdbc.Size;
@ -60,13 +59,19 @@ import jakarta.persistence.MapKeyColumn;
import jakarta.persistence.MapKeyJoinColumn;
import jakarta.persistence.MapKeyJoinColumns;
import static org.hibernate.cfg.PropertyHolderBuilder.buildPropertyHolder;
/**
* Implementation to bind a Map
*
* @author Emmanuel Bernard
*/
public class MapBinder extends CollectionBinder {
public MapBinder(Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver, boolean sorted, MetadataBuildingContext buildingContext) {
public MapBinder(
Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver,
boolean sorted,
MetadataBuildingContext buildingContext) {
super( customTypeBeanResolver, sorted, buildingContext );
}
@ -236,7 +241,7 @@ public class MapBinder extends CollectionBinder {
}
}
CollectionPropertyHolder holder = PropertyHolderBuilder.buildPropertyHolder(
CollectionPropertyHolder holder = buildPropertyHolder(
mapValue,
StringHelper.qualify( mapValue.getRole(), "mapkey" ),
keyXClass,
@ -274,14 +279,10 @@ public class MapBinder extends CollectionBinder {
if ( AnnotatedClassType.EMBEDDABLE.equals( classType ) ) {
EntityBinder entityBinder = new EntityBinder();
PropertyData inferredData;
if ( isHibernateExtensionMapping() ) {
inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "index", keyXClass );
}
else {
//"key" is the JPA 2 prefix for map keys
inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "key", keyXClass );
}
PropertyData inferredData = isHibernateExtensionMapping()
? new PropertyPreloadedData(AccessType.PROPERTY, "index", keyXClass)
: new PropertyPreloadedData(AccessType.PROPERTY, "key", keyXClass);
//"key" is the JPA 2 prefix for map keys
//TODO be smart with isNullable
Component component = AnnotationBinder.fillComponent(
@ -300,7 +301,7 @@ public class MapBinder extends CollectionBinder {
mapValue.setIndex( component );
}
else {
final BasicValueBinder<?> elementBinder = new BasicValueBinder<>( BasicValueBinder.Kind.MAP_KEY, buildingContext );
final BasicValueBinder elementBinder = new BasicValueBinder( BasicValueBinder.Kind.MAP_KEY, buildingContext );
elementBinder.setReturnedClassName( mapKeyType );
AnnotatedColumn[] elementColumns = mapKeyColumns;
@ -347,7 +348,8 @@ public class MapBinder extends CollectionBinder {
final jakarta.persistence.ForeignKey foreignKey = getMapKeyForeignKey( property );
if ( foreignKey != null ) {
if ( foreignKey.value() == ConstraintMode.NO_CONSTRAINT
|| foreignKey.value() == ConstraintMode.PROVIDER_DEFAULT && getBuildingContext().getBuildingOptions().isNoConstraintByDefault() ) {
|| foreignKey.value() == ConstraintMode.PROVIDER_DEFAULT
&& getBuildingContext().getBuildingOptions().isNoConstraintByDefault() ) {
element.disableForeignKey();
}
else {
@ -440,7 +442,12 @@ public class MapBinder extends CollectionBinder {
newProperty.setSelectable( current.isSelectable() );
newProperty.setValue(
createFormulatedValue(
current.getValue(), collection, targetPropertyName, associatedClass, associatedClass, buildingContext
current.getValue(),
collection,
targetPropertyName,
associatedClass,
associatedClass,
buildingContext
)
);
indexComponent.addProperty( newProperty );

View File

@ -71,7 +71,7 @@ public class PropertyBinder {
private boolean insertable = true;
private boolean updatable = true;
private String cascade;
private BasicValueBinder<?> basicValueBinder;
private BasicValueBinder basicValueBinder;
private XClass declaringClass;
private boolean declaringClassSet;
private boolean embedded;
@ -179,7 +179,7 @@ public class PropertyBinder {
final String containerClassName = holder.getClassName();
holder.startingProperty( property );
basicValueBinder = new BasicValueBinder<>( BasicValueBinder.Kind.ATTRIBUTE, buildingContext );
basicValueBinder = new BasicValueBinder( BasicValueBinder.Kind.ATTRIBUTE, buildingContext );
basicValueBinder.setPropertyName( name );
basicValueBinder.setReturnedClassName( returnedClassName );
basicValueBinder.setColumns( columns );
@ -525,7 +525,7 @@ public class PropertyBinder {
this.returnedClass = returnedClass;
}
public BasicValueBinder<?> getBasicValueBinder() {
public BasicValueBinder getBasicValueBinder() {
return basicValueBinder;
}

View File

@ -21,7 +21,11 @@ import org.hibernate.usertype.UserCollectionType;
* @author Matthew Inger
*/
public class SetBinder extends CollectionBinder {
public SetBinder(Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver, boolean sorted, MetadataBuildingContext buildingContext) {
public SetBinder(
Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver,
boolean sorted,
MetadataBuildingContext buildingContext) {
super( customTypeBeanResolver, sorted, buildingContext );
}