56
56
import org .springframework .data .mapping .SimpleAssociationHandler ;
57
57
import org .springframework .data .mapping .context .PersistentEntities ;
58
58
import org .springframework .data .rest .core .config .RepositoryRestConfiguration ;
59
+ import org .springframework .data .rest .core .mapping .ResourceMapping ;
59
60
import org .springframework .data .rest .core .mapping .ResourceMappings ;
60
61
import org .springframework .data .rest .core .mapping .ResourceMetadata ;
61
62
import org .springframework .data .rest .webmvc .RestMediaTypes ;
@@ -417,8 +418,11 @@ private List<String> getAssociationsFields(ResourceMetadata
417
418
List <String > associationsFields = new ArrayList <>();
418
419
entity .doWithAssociations ((SimpleAssociationHandler ) association -> {
419
420
PersistentProperty <?> property = association .getInverse ();
420
- String filedName = resourceMetadata .getMappingFor (property ).getRel ().value ();
421
- associationsFields .add (filedName );
421
+ ResourceMapping mapping = resourceMetadata .getMappingFor (property );
422
+ if (mapping .isExported ()) {
423
+ String filedName = mapping .getRel ().value ();
424
+ associationsFields .add (filedName );
425
+ }
422
426
});
423
427
return associationsFields ;
424
428
}
@@ -438,8 +442,11 @@ private List<String> getIgnoredFields(ResourceMetadata
438
442
ignoredFields .add (idField );
439
443
entity .doWithAssociations ((SimpleAssociationHandler ) association -> {
440
444
PersistentProperty <?> property = association .getInverse ();
441
- String filedName = resourceMetadata .getMappingFor (property ).getRel ().value ();
442
- ignoredFields .add (filedName );
445
+ ResourceMapping mapping = resourceMetadata .getMappingFor (property );
446
+ if (mapping .isExported ()) {
447
+ String filedName = mapping .getRel ().value ();
448
+ ignoredFields .add (filedName );
449
+ }
443
450
});
444
451
}
445
452
return ignoredFields ;
0 commit comments