12
12
13
13
import org .hibernate .boot .MappingException ;
14
14
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmColumnType ;
15
- import org .hibernate .boot .model .TruthValue ;
16
15
import org .hibernate .boot .model .source .spi .ColumnSource ;
17
16
import org .hibernate .boot .model .source .spi .DerivedValueSource ;
18
17
import org .hibernate .boot .model .source .spi .RelationalValueSource ;
19
18
import org .hibernate .boot .model .source .spi .SizeSource ;
20
- import org .hibernate .internal .util .StringHelper ;
21
19
import org .hibernate .internal .util .collections .CollectionHelper ;
22
20
21
+ import static org .hibernate .internal .util .StringHelper .isNotEmpty ;
22
+
23
23
/**
24
24
* @author Steve Ebersole
25
25
*/
@@ -152,7 +152,7 @@ public static RelationalValueSource buildValueSource(
152
152
if ( sources .size () > 1 ) {
153
153
final String errorMessage ;
154
154
if ( columnsAndFormulasSource .getSourceType ().canBeNamed ()
155
- && StringHelper . isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
155
+ && isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
156
156
errorMessage = String .format (
157
157
Locale .ENGLISH ,
158
158
"Expecting just a single formula/column in context of <%s name=\" %s\" />" ,
@@ -197,7 +197,7 @@ public static ColumnSource buildColumnSource(
197
197
if ( sources .size () > 1 ) {
198
198
final String errorMessage ;
199
199
if ( columnsAndFormulasSource .getSourceType ().canBeNamed ()
200
- && StringHelper . isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
200
+ && isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
201
201
errorMessage = String .format (
202
202
Locale .ENGLISH ,
203
203
"Expecting just a single formula/column in context of <%s name=\" %s\" />" ,
@@ -219,7 +219,7 @@ public static ColumnSource buildColumnSource(
219
219
if ( !(result instanceof ColumnSource ) ) {
220
220
final String errorMessage ;
221
221
if ( columnsAndFormulasSource .getSourceType ().canBeNamed ()
222
- && StringHelper . isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
222
+ && isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
223
223
errorMessage = String .format (
224
224
Locale .ENGLISH ,
225
225
"Expecting single column in context of <%s name=\" %s\" />, but found formula [%s]" ,
@@ -267,7 +267,7 @@ public static List<ColumnSource> buildColumnSources(
267
267
if ( !(source instanceof ColumnSource ) ) {
268
268
final String errorMessage ;
269
269
if ( columnsAndFormulasSource .getSourceType ().canBeNamed ()
270
- && StringHelper . isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
270
+ && isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
271
271
errorMessage = String .format (
272
272
Locale .ENGLISH ,
273
273
"Expecting only columns in context of <%s name=\" %s\" />, but found formula [%s]" ,
@@ -307,7 +307,7 @@ public static List<RelationalValueSource> buildValueSources(
307
307
ColumnsAndFormulasSource columnsAndFormulasSource ) {
308
308
List <RelationalValueSource > result = new ArrayList <>();
309
309
310
- if ( StringHelper . isNotEmpty ( columnsAndFormulasSource .getFormulaAttribute () ) ) {
310
+ if ( isNotEmpty ( columnsAndFormulasSource .getFormulaAttribute () ) ) {
311
311
// we have an explicit formula attribute (i.e., <SOMETHING formula="abc"/>)
312
312
validateUseOfFormulaAttribute ( mappingDocument , columnsAndFormulasSource );
313
313
@@ -359,8 +359,8 @@ else if ( selectable instanceof String ) {
359
359
containingTableName ,
360
360
columnsAndFormulasSource .getColumnAttribute (),
361
361
columnsAndFormulasSource .getSizeSource (),
362
- interpretNullabilityToTruthValue ( columnsAndFormulasSource .isNullable () ),
363
- columnsAndFormulasSource .isUnique () ? TruthValue . TRUE : TruthValue . FALSE ,
362
+ columnsAndFormulasSource .isNullable (),
363
+ columnsAndFormulasSource .isUnique (),
364
364
columnsAndFormulasSource .getIndexConstraintNames (),
365
365
columnsAndFormulasSource .getUniqueKeyConstraintNames ()
366
366
)
@@ -370,23 +370,14 @@ else if ( selectable instanceof String ) {
370
370
return result ;
371
371
}
372
372
373
- private static TruthValue interpretNullabilityToTruthValue (Boolean nullable ) {
374
- if ( nullable == null ) {
375
- return TruthValue .UNKNOWN ;
376
- }
377
- else {
378
- return nullable ? TruthValue .TRUE : TruthValue .FALSE ;
379
- }
380
- }
381
-
382
373
private static void validateUseOfFormulaAttribute (
383
374
MappingDocument sourceDocument ,
384
375
ColumnsAndFormulasSource columnsAndFormulasSource ) {
385
376
// 1) make sure there is no column attribute
386
- if ( StringHelper . isNotEmpty ( columnsAndFormulasSource .getColumnAttribute () ) ) {
377
+ if ( isNotEmpty ( columnsAndFormulasSource .getColumnAttribute () ) ) {
387
378
final String errorMessage ;
388
379
if ( columnsAndFormulasSource .getSourceType ().canBeNamed ()
389
- && StringHelper . isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
380
+ && isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
390
381
errorMessage = String .format (
391
382
Locale .ENGLISH ,
392
383
"column attribute and formula attribute may not be specified together near <%s name=\" %s\" column=\" %s\" formula=\" %s\" />" ,
@@ -411,7 +402,7 @@ private static void validateUseOfFormulaAttribute(
411
402
if ( CollectionHelper .isNotEmpty ( columnsAndFormulasSource .getColumnOrFormulaElements () ) ) {
412
403
final String errorMessage ;
413
404
if ( columnsAndFormulasSource .getSourceType ().canBeNamed ()
414
- && StringHelper . isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
405
+ && isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
415
406
errorMessage = String .format (
416
407
Locale .ENGLISH ,
417
408
"formula attribute may not be specified along with <column/> or <formula/> subelement(s) near <%s name=\" %s\" formula=\" %s\" />" ,
@@ -435,10 +426,10 @@ private static void validateUseOfFormulaAttribute(
435
426
private static void validateUseOfColumnOrFormulaNestedElements (
436
427
MappingDocument sourceDocument ,
437
428
ColumnsAndFormulasSource columnsAndFormulasSource ) {
438
- if ( StringHelper . isNotEmpty ( columnsAndFormulasSource .getColumnAttribute () ) ) {
429
+ if ( isNotEmpty ( columnsAndFormulasSource .getColumnAttribute () ) ) {
439
430
final String errorMessage ;
440
431
if ( columnsAndFormulasSource .getSourceType ().canBeNamed ()
441
- && StringHelper . isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
432
+ && isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
442
433
errorMessage = String .format (
443
434
Locale .ENGLISH ,
444
435
"column attribute may not be specified along with <column/> or <formula/> subelement(s) near <%s name=\" %s\" column=\" %s\" />" ,
@@ -467,7 +458,7 @@ private static void validateCustomWriteFragment(
467
458
if ( customWrite != null && !customWrite .matches ("[^?]*\\ ?[^?]*" ) ) {
468
459
final String errorMessage ;
469
460
if ( columnsAndFormulasSource .getSourceType ().canBeNamed ()
470
- && StringHelper . isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
461
+ && isNotEmpty ( columnsAndFormulasSource .getSourceName () ) ) {
471
462
errorMessage = String .format (
472
463
Locale .ENGLISH ,
473
464
"write expression must contain exactly one value placeholder ('?') character near <column name=\" %s\" ... write=\" %s\" /> for <%s name=\" %s\" />" ,
0 commit comments