39
39
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmCompositeIdType ;
40
40
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmCompositeKeyBasicAttributeType ;
41
41
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmCompositeKeyManyToOneType ;
42
+ import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmConfigParameterContainer ;
42
43
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmConfigParameterType ;
43
44
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmDiscriminatorSubclassEntityType ;
44
45
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmDynamicComponentType ;
91
92
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmSubclassEntityBaseDefinition ;
92
93
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmSynchronizeType ;
93
94
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmTimestampAttributeType ;
95
+ import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmTypeDefinitionType ;
96
+ import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmTypeSpecificationType ;
94
97
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmUnionSubclassEntityType ;
95
98
import org .hibernate .boot .jaxb .hbm .spi .JaxbHbmVersionAttributeType ;
96
99
import org .hibernate .boot .jaxb .hbm .spi .PluralAttributeInfo ;
103
106
import org .hibernate .boot .jaxb .mapping .spi .JaxbAttributesContainer ;
104
107
import org .hibernate .boot .jaxb .mapping .spi .JaxbAttributesContainerImpl ;
105
108
import org .hibernate .boot .jaxb .mapping .spi .JaxbBasicImpl ;
109
+ import org .hibernate .boot .jaxb .mapping .spi .JaxbBasicMapping ;
106
110
import org .hibernate .boot .jaxb .mapping .spi .JaxbCachingImpl ;
107
111
import org .hibernate .boot .jaxb .mapping .spi .JaxbCascadeTypeImpl ;
108
112
import org .hibernate .boot .jaxb .mapping .spi .JaxbCheckConstraintImpl ;
127
131
import org .hibernate .boot .jaxb .mapping .spi .JaxbFetchProfileImpl ;
128
132
import org .hibernate .boot .jaxb .mapping .spi .JaxbFieldResultImpl ;
129
133
import org .hibernate .boot .jaxb .mapping .spi .JaxbFilterDefImpl ;
134
+ import org .hibernate .boot .jaxb .mapping .spi .JaxbFilterImpl ;
130
135
import org .hibernate .boot .jaxb .mapping .spi .JaxbForeignKeyImpl ;
131
136
import org .hibernate .boot .jaxb .mapping .spi .JaxbGeneratedValueImpl ;
132
137
import org .hibernate .boot .jaxb .mapping .spi .JaxbGenericIdGeneratorImpl ;
133
- import org .hibernate .boot .jaxb .mapping .spi .JaxbHbmFilterImpl ;
134
138
import org .hibernate .boot .jaxb .mapping .spi .JaxbHqlImportImpl ;
135
139
import org .hibernate .boot .jaxb .mapping .spi .JaxbIdClassImpl ;
136
140
import org .hibernate .boot .jaxb .mapping .spi .JaxbIdImpl ;
@@ -256,7 +260,6 @@ private void doTransform() {
256
260
transfer ( hbmXmlMapping ::isDefaultLazy , ormRoot ::setDefaultLazy );
257
261
258
262
transferIdentifierGenerators ();
259
- transferTypeDefs ();
260
263
transferFilterDefinitions ();
261
264
transferImports ();
262
265
transferEntities ();
@@ -320,7 +323,7 @@ private void handleUnsupported(PickHandler pickHandler, String message, Object..
320
323
Locale .ROOT ,
321
324
message ,
322
325
messageArgs
323
- )
326
+ ) + " (" + origin + ")"
324
327
);
325
328
case PICK -> {
326
329
if ( pickHandler != null ) {
@@ -332,17 +335,6 @@ private void handleUnsupported(PickHandler pickHandler, String message, Object..
332
335
}
333
336
}
334
337
335
- private void transferTypeDefs () {
336
- if ( hbmXmlMapping .getTypedef ().isEmpty () ) {
337
- return ;
338
- }
339
-
340
- handleUnsupported (
341
- "Transformation of type-def mapping not supported - `%s`" ,
342
- origin
343
- );
344
- }
345
-
346
338
private void transferIdentifierGenerators () {
347
339
if ( hbmXmlMapping .getIdentifierGenerator ().isEmpty () ) {
348
340
return ;
@@ -1385,22 +1377,7 @@ private void transferBasicAttribute(JaxbHbmBasicAttributeType hbmProp, JaxbBasic
1385
1377
basic .setAttributeAccessor ( hbmProp .getAccess () );
1386
1378
basic .setOptimisticLock ( hbmProp .isOptimisticLock () );
1387
1379
1388
- if ( isNotEmpty ( hbmProp .getTypeAttribute () ) ) {
1389
- basic .setType ( new JaxbUserTypeImpl () );
1390
- basic .getType ().setValue ( hbmProp .getTypeAttribute () );
1391
- }
1392
- else {
1393
- if ( hbmProp .getType () != null ) {
1394
- basic .setType ( new JaxbUserTypeImpl () );
1395
- basic .getType ().setValue ( hbmProp .getType ().getName () );
1396
- for ( JaxbHbmConfigParameterType hbmParam : hbmProp .getType ().getConfigParameters () ) {
1397
- final JaxbConfigurationParameterImpl param = new JaxbConfigurationParameterImpl ();
1398
- param .setName ( hbmParam .getName () );
1399
- param .setValue ( hbmParam .getValue () );
1400
- basic .getType ().getParameters ().add ( param );
1401
- }
1402
- }
1403
- }
1380
+ applyBasicType ( basic , hbmProp .getTypeAttribute (), hbmProp .getType () );
1404
1381
1405
1382
transferColumnsAndFormulas (
1406
1383
new ColumnAndFormulaSource () {
@@ -1484,6 +1461,56 @@ public Boolean isUpdateable() {
1484
1461
);
1485
1462
}
1486
1463
1464
+ private void applyBasicType (JaxbBasicMapping target , String hbmTypeAttribute , JaxbHbmTypeSpecificationType hbmTypeNode ) {
1465
+ if ( isNotEmpty ( hbmTypeAttribute ) ) {
1466
+ final JaxbUserTypeImpl typeNode = interpretBasicType (
1467
+ hbmTypeAttribute ,
1468
+ null ,
1469
+ transformationState .getTypeDefinitionMap ().get ( hbmTypeAttribute )
1470
+ );
1471
+ target .setType ( typeNode );
1472
+ }
1473
+
1474
+ if ( hbmTypeNode != null ) {
1475
+ final JaxbUserTypeImpl typeNode = interpretBasicType (
1476
+ hbmTypeNode .getName (),
1477
+ hbmTypeNode ,
1478
+ transformationState .getTypeDefinitionMap ().get ( hbmTypeNode .getName () )
1479
+ );
1480
+ target .setType ( typeNode );
1481
+ }
1482
+ }
1483
+
1484
+ private JaxbUserTypeImpl interpretBasicType (String typeName , JaxbHbmConfigParameterContainer typeLocalParams , JaxbHbmTypeDefinitionType typeDef ) {
1485
+ assert StringHelper .isNotEmpty ( typeName );
1486
+
1487
+ final JaxbUserTypeImpl typeNode = new JaxbUserTypeImpl ();
1488
+
1489
+ if ( typeDef == null ) {
1490
+ typeNode .setValue ( typeName );
1491
+ }
1492
+ else {
1493
+ typeNode .setValue ( typeDef .getClazz () );
1494
+ for ( JaxbHbmConfigParameterType hbmParam : typeDef .getConfigParameters () ) {
1495
+ final JaxbConfigurationParameterImpl param = new JaxbConfigurationParameterImpl ();
1496
+ param .setName ( hbmParam .getName () );
1497
+ param .setValue ( hbmParam .getValue () );
1498
+ typeNode .getParameters ().add ( param );
1499
+ }
1500
+ }
1501
+
1502
+ if ( typeLocalParams != null ) {
1503
+ for ( JaxbHbmConfigParameterType hbmParam : typeLocalParams .getConfigParameters () ) {
1504
+ final JaxbConfigurationParameterImpl param = new JaxbConfigurationParameterImpl ();
1505
+ param .setName ( hbmParam .getName () );
1506
+ param .setValue ( hbmParam .getValue () );
1507
+ typeNode .getParameters ().add ( param );
1508
+ }
1509
+ }
1510
+
1511
+ return typeNode ;
1512
+ }
1513
+
1487
1514
private JaxbEmbeddableImpl applyEmbeddable (JaxbEntityMappingsImpl ormRoot , JaxbHbmCompositeAttributeType hbmComponent ) {
1488
1515
final String embeddableClassName = hbmComponent .getClazz ();
1489
1516
if ( StringHelper .isNotEmpty ( embeddableClassName ) ) {
@@ -2057,9 +2084,6 @@ private void transferOneToManyInfo(
2057
2084
if ( StringHelper .isNotEmpty ( hbmAttributeInfo .getCollectionType () ) ) {
2058
2085
handleUnsupported ( "Collection-type is not supported for transformation" );
2059
2086
}
2060
- if ( CollectionHelper .isNotEmpty ( hbmAttributeInfo .getFilter () ) ) {
2061
- handleUnsupported ( "Filters are not supported for transformation" );
2062
- }
2063
2087
if ( StringHelper .isNotEmpty ( hbmAttributeInfo .getWhere () ) ) {
2064
2088
handleUnsupported ( "SQL restrictions are not supported for transformation" );
2065
2089
}
@@ -2082,9 +2106,6 @@ private void transferOneToManyInfo(
2082
2106
if ( !(hbmOneToMany .getNode () == null || hbmOneToMany .getNode ().isBlank () ) ) {
2083
2107
handleUnsupported ( "`node` not supported for transformation" );
2084
2108
}
2085
- if ( hbmOneToMany .getNotFound () != null ) {
2086
- target .setNotFound ( interpretNotFoundAction ( hbmOneToMany .getNotFound () ) );
2087
- }
2088
2109
2089
2110
transferCollectionBasicInfo ( hbmAttributeInfo , target );
2090
2111
target .setTargetEntity ( StringHelper .isNotEmpty ( hbmOneToMany .getClazz () ) ? hbmOneToMany .getClazz () : hbmOneToMany .getEntityName () );
@@ -2104,8 +2125,16 @@ private void transferOneToManyInfo(
2104
2125
// oneToMany.setOnDelete( ?? );
2105
2126
}
2106
2127
2128
+ if ( hbmOneToMany .getNotFound () != null ) {
2129
+ target .setNotFound ( interpretNotFoundAction ( hbmOneToMany .getNotFound () ) );
2130
+ }
2131
+
2107
2132
target .setOrphanRemoval ( isOrphanRemoval ( hbmAttributeInfo .getCascade () ) );
2108
2133
target .setCascade ( convertCascadeType ( hbmAttributeInfo .getCascade () ) );
2134
+
2135
+ for ( JaxbHbmFilterType hbmFilter : hbmAttributeInfo .getFilter () ) {
2136
+ target .getFilters ().add ( convert ( hbmFilter ) );
2137
+ }
2109
2138
}
2110
2139
2111
2140
private JaxbManyToManyImpl transformManyToMany (PluralAttributeInfo hbmCollection ) {
@@ -2121,9 +2150,6 @@ private void transferManyToManyInfo(
2121
2150
if ( StringHelper .isNotEmpty ( hbmCollection .getCollectionType () ) ) {
2122
2151
handleUnsupported ( "Collection-type is not supported for transformation" );
2123
2152
}
2124
- if ( CollectionHelper .isNotEmpty ( hbmCollection .getFilter () ) ) {
2125
- handleUnsupported ( "Filters are not supported for transformation" );
2126
- }
2127
2153
if ( StringHelper .isNotEmpty ( hbmCollection .getWhere () ) ) {
2128
2154
handleUnsupported ( "SQL restrictions are not supported for transformation" );
2129
2155
}
@@ -2152,6 +2178,10 @@ private void transferManyToManyInfo(
2152
2178
2153
2179
transferCollectionBasicInfo ( hbmCollection , target );
2154
2180
target .setTargetEntity ( StringHelper .isNotEmpty ( manyToMany .getClazz () ) ? manyToMany .getClazz () : manyToMany .getEntityName () );
2181
+
2182
+ for ( JaxbHbmFilterType hbmFilter : hbmCollection .getFilter () ) {
2183
+ target .getFilters ().add ( convert ( hbmFilter ) );
2184
+ }
2155
2185
}
2156
2186
2157
2187
private JaxbPluralAnyMappingImpl transformPluralAny (PluralAttributeInfo hbmCollection ) {
@@ -2285,9 +2315,7 @@ private JaxbIdImpl convertSimpleId(JaxbHbmSimpleIdType source) {
2285
2315
}
2286
2316
}
2287
2317
2288
- // if ( isNotEmpty( source.getTypeAttribute() ) || source.getType() != null ) {
2289
- // handleUnsupported( "<id/> specified type which is not supported" );
2290
- // }
2318
+ applyBasicType ( target , source .getTypeAttribute (), source .getType () );
2291
2319
2292
2320
target .setUnsavedValue ( source .getUnsavedValue () );
2293
2321
@@ -2632,8 +2660,8 @@ private OnDeleteAction convert(JaxbHbmOnDeleteEnum hbmOnDelete) {
2632
2660
return hbmOnDelete == JaxbHbmOnDeleteEnum .CASCADE ? OnDeleteAction .CASCADE : OnDeleteAction .NO_ACTION ;
2633
2661
}
2634
2662
2635
- private JaxbHbmFilterImpl convert (JaxbHbmFilterType hbmFilter ) {
2636
- final JaxbHbmFilterImpl filter = new JaxbHbmFilterImpl ();
2663
+ private JaxbFilterImpl convert (JaxbHbmFilterType hbmFilter ) {
2664
+ final JaxbFilterImpl filter = new JaxbFilterImpl ();
2637
2665
filter .setName ( hbmFilter .getName () );
2638
2666
2639
2667
final boolean shouldAutoInjectAliases = hbmFilter .getAutoAliasInjection () == null
@@ -2648,7 +2676,7 @@ private JaxbHbmFilterImpl convert(JaxbHbmFilterType hbmFilter) {
2648
2676
}
2649
2677
else {
2650
2678
final JaxbHbmFilterAliasMappingType hbmAliasMapping = (JaxbHbmFilterAliasMappingType ) content ;
2651
- final JaxbHbmFilterImpl .JaxbAliasesImpl aliasMapping = new JaxbHbmFilterImpl .JaxbAliasesImpl ();
2679
+ final JaxbFilterImpl .JaxbAliasesImpl aliasMapping = new JaxbFilterImpl .JaxbAliasesImpl ();
2652
2680
aliasMapping .setAlias ( hbmAliasMapping .getAlias () );
2653
2681
aliasMapping .setEntity ( hbmAliasMapping .getEntity () );
2654
2682
aliasMapping .setTable ( hbmAliasMapping .getTable () );
0 commit comments