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