5656import org .springframework .data .mapping .SimpleAssociationHandler ;
5757import org .springframework .data .mapping .context .PersistentEntities ;
5858import org .springframework .data .rest .core .config .RepositoryRestConfiguration ;
59+ import org .springframework .data .rest .core .mapping .ResourceMapping ;
5960import org .springframework .data .rest .core .mapping .ResourceMappings ;
6061import org .springframework .data .rest .core .mapping .ResourceMetadata ;
6162import org .springframework .data .rest .webmvc .RestMediaTypes ;
@@ -417,8 +418,11 @@ private List<String> getAssociationsFields(ResourceMetadata
417418 List <String > associationsFields = new ArrayList <>();
418419 entity .doWithAssociations ((SimpleAssociationHandler ) association -> {
419420 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+ }
422426 });
423427 return associationsFields ;
424428 }
@@ -438,8 +442,11 @@ private List<String> getIgnoredFields(ResourceMetadata
438442 ignoredFields .add (idField );
439443 entity .doWithAssociations ((SimpleAssociationHandler ) association -> {
440444 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+ }
443450 });
444451 }
445452 return ignoredFields ;
0 commit comments