Skip to content

Commit 23eabd9

Browse files
SweetWuXiaoMeiliubao68
authored andcommitted
HHH-19365 - fixed CodeQL
1 parent 9eae5e6 commit 23eabd9

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/GaussDBAbstractStructuredJdbcType.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,7 @@ private int deserializeStruct(
375375
string,
376376
start,
377377
i
378-
),
379-
jdbcMapping.getJdbcJavaType()
378+
)
380379
),
381380
options
382381
);
@@ -765,8 +764,7 @@ private int deserializeArray(
765764
string,
766765
start,
767766
i
768-
),
769-
elementType.getJdbcJavaType()
767+
)
770768
),
771769
options
772770
)
@@ -1001,14 +999,14 @@ private SelectableMapping getJdbcValueSelectable(int jdbcValueSelectableIndex) {
1001999
int count = 0;
10021000
for ( int i = 0; i < size; i++ ) {
10031001
final ValuedModelPart modelPart = getEmbeddedPart( embeddableMappingType, orderMapping[i] );
1004-
if ( modelPart.getMappedType() instanceof EmbeddableMappingType embeddableMappingType ) {
1005-
final SelectableMapping aggregateMapping = embeddableMappingType.getAggregateMapping();
1002+
if ( modelPart.getMappedType() instanceof EmbeddableMappingType nestEmbeddableMappingType ) {
1003+
final SelectableMapping aggregateMapping = nestEmbeddableMappingType.getAggregateMapping();
10061004
if ( aggregateMapping == null ) {
1007-
final SelectableMapping subSelectable = embeddableMappingType.getJdbcValueSelectable( jdbcValueSelectableIndex - count );
1005+
final SelectableMapping subSelectable = nestEmbeddableMappingType.getJdbcValueSelectable( jdbcValueSelectableIndex - count );
10081006
if ( subSelectable != null ) {
10091007
return subSelectable;
10101008
}
1011-
count += embeddableMappingType.getJdbcValueCount();
1009+
count += nestEmbeddableMappingType.getJdbcValueCount();
10121010
}
10131011
else {
10141012
if ( count == jdbcValueSelectableIndex ) {
@@ -1110,7 +1108,7 @@ private Object parseTime(CharSequence subSequence) {
11101108
return DateTimeFormatter.ISO_LOCAL_TIME.parse( subSequence, LocalTime::from );
11111109
}
11121110

1113-
private Object parseTimestamp(CharSequence subSequence, JavaType<?> jdbcJavaType) {
1111+
private Object parseTimestamp(CharSequence subSequence) {
11141112
final TemporalAccessor temporalAccessor = LOCAL_DATE_TIME.parse( subSequence );
11151113
final LocalDateTime localDateTime = LocalDateTime.from( temporalAccessor );
11161114
final Timestamp timestamp = Timestamp.valueOf( localDateTime );
@@ -1257,7 +1255,7 @@ private void serializeConvertedBasicTo(
12571255
case SqlTypes.DECIMAL:
12581256
case SqlTypes.NUMERIC:
12591257
case SqlTypes.DURATION:
1260-
appender.append( subValue.toString() );
1258+
appender.append( subValue != null ? subValue.toString() : "");
12611259
break;
12621260
case SqlTypes.CHAR:
12631261
case SqlTypes.NCHAR:
@@ -1306,7 +1304,7 @@ private void serializeConvertedBasicTo(
13061304
);
13071305
break;
13081306
case SqlTypes.UUID:
1309-
appender.append( subValue.toString() );
1307+
appender.append( subValue != null ? subValue.toString() : "");
13101308
break;
13111309
case SqlTypes.ARRAY:
13121310
if ( subValue != null ) {

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/GaussDBDialect.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,14 @@ public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
778778
new TemplatedViolatedConstraintNameExtractor( sqle -> {
779779
final String sqlState = JdbcExceptionHelper.extractSqlState( sqle );
780780
if ( sqlState != null ) {
781-
switch ( Integer.parseInt( sqlState ) ) {
781+
int state;
782+
try {
783+
state = Integer.parseInt(sqlState);
784+
}
785+
catch (NumberFormatException e) {
786+
state = 23001; // or some default value
787+
}
788+
switch ( state ) {
782789
// CHECK VIOLATION
783790
case 23514:
784791
return extractUsingTemplate( "violates check constraint \"", "\"", sqle.getMessage() );
@@ -1207,13 +1214,13 @@ public void augmentRecognizedTableTypes(List<String> tableTypesList) {
12071214
@Override
12081215
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
12091216
super.contributeTypes(typeContributions, serviceRegistry);
1210-
contributeGaussDBTypes( typeContributions, serviceRegistry);
1217+
contributeGaussDBTypes( typeContributions);
12111218
}
12121219

12131220
/**
12141221
* Allow for extension points to override this only
12151222
*/
1216-
protected void contributeGaussDBTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
1223+
protected void contributeGaussDBTypes(TypeContributions typeContributions) {
12171224
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
12181225
.getJdbcTypeRegistry();
12191226
// For how BLOB affects Hibernate, see:

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/aggregate/GaussDBAggregateSupport.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.util.LinkedHashMap;
88
import java.util.Map;
99

10-
import org.hibernate.dialect.Dialect;
1110
import org.hibernate.dialect.aggregate.AggregateSupport;
1211
import org.hibernate.dialect.aggregate.AggregateSupportImpl;
1312
import org.hibernate.internal.util.StringHelper;
@@ -61,7 +60,7 @@ public class GaussDBAggregateSupport extends AggregateSupportImpl {
6160
private static final String XML_QUERY_SEPARATOR = "' passing ";
6261
private static final String XML_QUERY_END = " columns v xml path '.')t)";
6362

64-
public static AggregateSupport valueOf(Dialect dialect) {
63+
public static AggregateSupport valueOf() {
6564
return GaussDBAggregateSupport.INSTANCE;
6665
}
6766

0 commit comments

Comments
 (0)