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 2121 */
2222public class PropertyAccessStrategyEnhancedImpl implements PropertyAccessStrategy {
2323 public static PropertyAccessStrategyEnhancedImpl with (AccessType getterAccessType ) {
24- if ( getterAccessType == AccessType . FIELD ) {
25- return FIELD ;
24+ if ( getterAccessType == null ) {
25+ return STANDARD ;
2626 }
27- return STANDARD ;
27+
28+ return switch ( getterAccessType ) {
29+ case FIELD -> FIELD ;
30+ case PROPERTY -> PROPERTY ;
31+ };
2832 }
2933
3034 private final @ Nullable AccessType getterAccessType ;
3135
3236 public static PropertyAccessStrategyEnhancedImpl STANDARD = new PropertyAccessStrategyEnhancedImpl ( null );
3337 public static PropertyAccessStrategyEnhancedImpl FIELD = new PropertyAccessStrategyEnhancedImpl ( AccessType .FIELD );
38+ public static PropertyAccessStrategyEnhancedImpl PROPERTY = new PropertyAccessStrategyEnhancedImpl ( AccessType .PROPERTY );
3439
3540 public PropertyAccessStrategyEnhancedImpl (@ Nullable AccessType getterAccessType ) {
3641 this .getterAccessType = getterAccessType ;
Original file line number Diff line number Diff line change 88
99import org .hibernate .HibernateException ;
1010import org .hibernate .boot .registry .selector .spi .StrategySelector ;
11+ import org .hibernate .boot .spi .AccessType ;
1112import org .hibernate .internal .util .StringHelper ;
1213import org .hibernate .metamodel .RepresentationMode ;
1314import org .hibernate .property .access .spi .BuiltInPropertyAccessStrategies ;
@@ -40,9 +41,12 @@ public PropertyAccessStrategy resolvePropertyAccessStrategy(
4041 || BuiltInPropertyAccessStrategies .MIXED .getExternalName ().equals ( explicitAccessStrategyName ) ) {
4142 //type-cache-pollution agent: it's crucial to use the ManagedTypeHelper rather than attempting a direct cast
4243 if ( isManagedType ( containerClass ) ) {
43- if ( BuiltInPropertyAccessStrategies .FIELD .getExternalName ().equals ( explicitAccessStrategyName ) ) {
44+ if ( AccessType .FIELD .getType ().equals ( explicitAccessStrategyName ) ) {
4445 return PropertyAccessStrategyEnhancedImpl .FIELD ;
4546 }
47+ else if ( AccessType .PROPERTY .getType ().equals ( explicitAccessStrategyName ) ) {
48+ return PropertyAccessStrategyEnhancedImpl .PROPERTY ;
49+ }
4650 return PropertyAccessStrategyEnhancedImpl .STANDARD ;
4751 }
4852 }
You can’t perform that action at this time.
0 commit comments