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 1919 */
2020public class PropertyAccessStrategyEnhancedImpl implements PropertyAccessStrategy {
2121 public static PropertyAccessStrategyEnhancedImpl with (AccessType getterAccessType ) {
22- if ( getterAccessType == AccessType . FIELD ) {
23- return FIELD ;
22+ if ( getterAccessType == null ) {
23+ return STANDARD ;
2424 }
25- return STANDARD ;
25+
26+ return switch ( getterAccessType ) {
27+ case FIELD -> FIELD ;
28+ case PROPERTY -> PROPERTY ;
29+ };
2630 }
2731
2832 private final @ Nullable AccessType getterAccessType ;
2933
3034 public static PropertyAccessStrategyEnhancedImpl STANDARD = new PropertyAccessStrategyEnhancedImpl ( null );
3135 public static PropertyAccessStrategyEnhancedImpl FIELD = new PropertyAccessStrategyEnhancedImpl ( AccessType .FIELD );
36+ public static PropertyAccessStrategyEnhancedImpl PROPERTY = new PropertyAccessStrategyEnhancedImpl ( AccessType .PROPERTY );
3237
3338 public PropertyAccessStrategyEnhancedImpl (@ Nullable AccessType getterAccessType ) {
3439 this .getterAccessType = getterAccessType ;
Original file line number Diff line number Diff line change 66
77import org .hibernate .HibernateException ;
88import org .hibernate .boot .registry .selector .spi .StrategySelector ;
9+ import org .hibernate .boot .spi .AccessType ;
910import org .hibernate .internal .util .StringHelper ;
1011import org .hibernate .metamodel .RepresentationMode ;
1112import org .hibernate .property .access .spi .BuiltInPropertyAccessStrategies ;
@@ -38,9 +39,12 @@ public PropertyAccessStrategy resolvePropertyAccessStrategy(
3839 || BuiltInPropertyAccessStrategies .MIXED .getExternalName ().equals ( explicitAccessStrategyName ) ) {
3940 //type-cache-pollution agent: it's crucial to use the ManagedTypeHelper rather than attempting a direct cast
4041 if ( isManagedType ( containerClass ) ) {
41- if ( BuiltInPropertyAccessStrategies .FIELD .getExternalName ().equals ( explicitAccessStrategyName ) ) {
42+ if ( AccessType .FIELD .getType ().equals ( explicitAccessStrategyName ) ) {
4243 return PropertyAccessStrategyEnhancedImpl .FIELD ;
4344 }
45+ else if ( AccessType .PROPERTY .getType ().equals ( explicitAccessStrategyName ) ) {
46+ return PropertyAccessStrategyEnhancedImpl .PROPERTY ;
47+ }
4448 return PropertyAccessStrategyEnhancedImpl .STANDARD ;
4549 }
4650 }
You can’t perform that action at this time.
0 commit comments