File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
hibernate-core/src/main/java/org/hibernate/property/access/internal Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 19
19
*/
20
20
public class PropertyAccessStrategyEnhancedImpl implements PropertyAccessStrategy {
21
21
public static PropertyAccessStrategyEnhancedImpl with (AccessType getterAccessType ) {
22
- if ( getterAccessType == AccessType . FIELD ) {
23
- return FIELD ;
22
+ if ( getterAccessType == null ) {
23
+ return STANDARD ;
24
24
}
25
- return STANDARD ;
25
+
26
+ return switch ( getterAccessType ) {
27
+ case FIELD -> FIELD ;
28
+ case PROPERTY -> PROPERTY ;
29
+ };
26
30
}
27
31
28
32
private final @ Nullable AccessType getterAccessType ;
29
33
30
34
public static PropertyAccessStrategyEnhancedImpl STANDARD = new PropertyAccessStrategyEnhancedImpl ( null );
31
35
public static PropertyAccessStrategyEnhancedImpl FIELD = new PropertyAccessStrategyEnhancedImpl ( AccessType .FIELD );
36
+ public static PropertyAccessStrategyEnhancedImpl PROPERTY = new PropertyAccessStrategyEnhancedImpl ( AccessType .PROPERTY );
32
37
33
38
public PropertyAccessStrategyEnhancedImpl (@ Nullable AccessType getterAccessType ) {
34
39
this .getterAccessType = getterAccessType ;
Original file line number Diff line number Diff line change 6
6
7
7
import org .hibernate .HibernateException ;
8
8
import org .hibernate .boot .registry .selector .spi .StrategySelector ;
9
+ import org .hibernate .boot .spi .AccessType ;
9
10
import org .hibernate .internal .util .StringHelper ;
10
11
import org .hibernate .metamodel .RepresentationMode ;
11
12
import org .hibernate .property .access .spi .BuiltInPropertyAccessStrategies ;
@@ -38,9 +39,12 @@ public PropertyAccessStrategy resolvePropertyAccessStrategy(
38
39
|| BuiltInPropertyAccessStrategies .MIXED .getExternalName ().equals ( explicitAccessStrategyName ) ) {
39
40
//type-cache-pollution agent: it's crucial to use the ManagedTypeHelper rather than attempting a direct cast
40
41
if ( isManagedType ( containerClass ) ) {
41
- if ( BuiltInPropertyAccessStrategies .FIELD .getExternalName ().equals ( explicitAccessStrategyName ) ) {
42
+ if ( AccessType .FIELD .getType ().equals ( explicitAccessStrategyName ) ) {
42
43
return PropertyAccessStrategyEnhancedImpl .FIELD ;
43
44
}
45
+ else if ( AccessType .PROPERTY .getType ().equals ( explicitAccessStrategyName ) ) {
46
+ return PropertyAccessStrategyEnhancedImpl .PROPERTY ;
47
+ }
44
48
return PropertyAccessStrategyEnhancedImpl .STANDARD ;
45
49
}
46
50
}
You can’t perform that action at this time.
0 commit comments