Skip to content

Commit dbdf54b

Browse files
committed
remove use of SessionFactoryImplementor in Instantiators and CompositeUserType
it was not needed and arguably a layer-breaker
1 parent 9a0948a commit dbdf54b

File tree

88 files changed

+534
-668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+534
-668
lines changed

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ protected <X> X fromString(String string, JavaType<X> javaType, WrapperOptions o
189189
if ( returnEmbeddable ) {
190190
final StructAttributeValues attributeValues = getAttributeValues( embeddableMappingType, orderMapping, array, options );
191191
//noinspection unchecked
192-
return (X) instantiate( embeddableMappingType, attributeValues, options.getSessionFactory() );
192+
return (X) instantiate( embeddableMappingType, attributeValues );
193193
}
194194
else if ( inverseOrderMapping != null ) {
195195
StructHelper.orderJdbcValues( embeddableMappingType, inverseOrderMapping, array.clone(), array );
@@ -468,8 +468,7 @@ private int deserializeStruct(
468468
subValues,
469469
options
470470
);
471-
final Object subValue = instantiate( structJdbcType.embeddableMappingType, attributeValues, options.getSessionFactory() );
472-
values[column] = subValue;
471+
values[column] = instantiate( structJdbcType.embeddableMappingType, attributeValues );
473472
}
474473
else {
475474
if ( structJdbcType.inverseOrderMapping != null ) {
@@ -849,9 +848,7 @@ private int deserializeArray(
849848
i += expectedQuotes - 1;
850849
if ( string.charAt( i + 1 ) == '(' ) {
851850
// This could be a nested struct
852-
if ( elementType.getJdbcType() instanceof AbstractPostgreSQLStructJdbcType ) {
853-
final AbstractPostgreSQLStructJdbcType structJdbcType;
854-
structJdbcType = (AbstractPostgreSQLStructJdbcType) elementType.getJdbcType();
851+
if ( elementType.getJdbcType() instanceof AbstractPostgreSQLStructJdbcType structJdbcType ) {
855852
final Object[] subValues = new Object[structJdbcType.embeddableMappingType.getJdbcValueCount()];
856853
final int subEnd = structJdbcType.deserializeStruct(
857854
string,
@@ -868,8 +865,7 @@ private int deserializeArray(
868865
subValues,
869866
options
870867
);
871-
final Object subValue = instantiate( structJdbcType.embeddableMappingType, attributeValues, options.getSessionFactory() );
872-
values.add( subValue );
868+
values.add( instantiate( structJdbcType.embeddableMappingType, attributeValues ) );
873869
}
874870
else {
875871
if ( structJdbcType.inverseOrderMapping != null ) {
@@ -1422,10 +1418,7 @@ private int injectAttributeValue(
14221418
subJdbcValues,
14231419
options
14241420
);
1425-
attributeValues.setAttributeValue(
1426-
attributeIndex,
1427-
instantiate( embeddableMappingType, subValues, options.getSessionFactory() )
1428-
);
1421+
attributeValues.setAttributeValue( attributeIndex, instantiate( embeddableMappingType, subValues ) );
14291422
}
14301423
}
14311424
else {

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,9 @@ private X getValue(SQLXML object, WrapperOptions options) throws SQLException {
166166

167167
@Override
168168
public SQLXML createJdbcValue(Object value, WrapperOptions options) throws SQLException {
169-
final SQLXML sqlxml = options.getSession()
170-
.getJdbcCoordinator()
171-
.getLogicalConnection()
172-
.getPhysicalConnection()
173-
.createSQLXML();
169+
final SQLXML sqlxml =
170+
options.getSession().getJdbcCoordinator().getLogicalConnection().getPhysicalConnection()
171+
.createSQLXML();
174172
sqlxml.setString( XmlHelper.toString( embeddableMappingType, value, options) );
175173
return sqlxml;
176174
}

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public static <X> X fromString(
356356
options
357357
);
358358
//noinspection unchecked
359-
return (X) instantiate( embeddableMappingType, attributeValues, options.getSessionFactory() );
359+
return (X) instantiate( embeddableMappingType, attributeValues );
360360
}
361361
//noinspection unchecked
362362
return (X) values;
@@ -378,8 +378,7 @@ public static <X> X arrayFromString(
378378
jdbcJavaType = elementJavaType;
379379
}
380380
else {
381-
jdbcJavaType = options.getSessionFactory().getTypeConfiguration().getJavaTypeRegistry()
382-
.resolveDescriptor( preferredJavaTypeClass );
381+
jdbcJavaType = options.getTypeConfiguration().getJavaTypeRegistry().resolveDescriptor( preferredJavaTypeClass );
383382
}
384383
final CustomArrayList arrayList = new CustomArrayList();
385384
final int i = fromArrayString(
@@ -527,7 +526,7 @@ private static int fromString(
527526
subValues,
528527
options
529528
);
530-
values[selectableIndex] = instantiate( embeddableMappingType, attributeValues, options.getSessionFactory() );
529+
values[selectableIndex] = instantiate( embeddableMappingType, attributeValues );
531530
}
532531
else {
533532
values[selectableIndex] = subValues;
@@ -1303,17 +1302,12 @@ else if ( jdbcJavaType instanceof EnumJavaType<?> ) {
13031302
subValues,
13041303
options
13051304
);
1306-
final EmbeddableMappingType embeddableMappingType = aggregateJdbcType.getEmbeddableMappingType();
1307-
return instantiate( embeddableMappingType, subAttributeValues, options.getSessionFactory() ) ;
1305+
return instantiate( aggregateJdbcType.getEmbeddableMappingType(), subAttributeValues ) ;
13081306
}
13091307
return subValues;
13101308
}
13111309

1312-
return jdbcJavaType.fromEncodedString(
1313-
string,
1314-
start,
1315-
end
1316-
);
1310+
return jdbcJavaType.fromEncodedString( string, start, end );
13171311
}
13181312
}
13191313

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ protected X doExtract(CallableStatement statement, String name, WrapperOptions o
147147
}
148148

149149
static String getTypeName(WrapperOptions options, BasicPluralJavaType<?> containerJavaType, ArrayJdbcType arrayJdbcType) {
150-
final Dialect dialect = options.getSessionFactory().getJdbcServices().getDialect();
151-
return getTypeName( containerJavaType.getElementJavaType(), arrayJdbcType.getElementJdbcType(), dialect );
150+
return getTypeName( containerJavaType.getElementJavaType(), arrayJdbcType.getElementJdbcType(), options.getDialect() );
152151
}
153152

154153
static String getTypeName(BasicType<?> elementType, Dialect dialect) {

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,8 @@ protected Object transformRawJdbcValue(Object rawJdbcValue, WrapperOptions optio
6868
return rawJdbcValue;
6969
}
7070
try {
71-
return rawJdbcTransformer.invoke(
72-
rawJdbcValue,
73-
options.getSession()
74-
.getJdbcCoordinator()
75-
.getLogicalConnection()
76-
.getPhysicalConnection()
77-
);
71+
return rawJdbcTransformer.invoke( rawJdbcValue,
72+
options.getSession().getJdbcCoordinator().getLogicalConnection().getPhysicalConnection() );
7873
}
7974
catch (Exception e) {
8075
throw new HibernateException( "Could not transform the raw jdbc value", e );

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ protected Object transformRawJdbcValue(Object rawJdbcValue, WrapperOptions optio
4848
if ( rawJdbcValue.getClass() == TIMESTAMPTZ.class ) {
4949
try {
5050
return ( (TIMESTAMPTZ) rawJdbcValue ).offsetDateTimeValue(
51-
options.getSession()
52-
.getJdbcCoordinator()
53-
.getLogicalConnection()
54-
.getPhysicalConnection()
51+
options.getSession().getJdbcCoordinator().getLogicalConnection().getPhysicalConnection()
5552
);
5653
}
5754
catch (Exception e) {

0 commit comments

Comments
 (0)