spring-data-mongodb icon indicating copy to clipboard operation
spring-data-mongodb copied to clipboard

Support interface projections on reference/association properties.

Open christophstrobl opened this issue 3 years ago • 0 comments

Currently it is only possible to include the target type within an interface projection when operating upon associations. It should be allowed to use interface projections on references using @DBRef.

public class WithRefs { // source domain type
	@Id String id;
	@DBRef Planet planet;
}
public interface ProjectPlanetUsingOriginalTargetType {
	Planet getPlanet(); 
}

template.query(WithRefs.class).as(ProjectPlanetUsingOriginalTargetType.class) // works
public interface ProjectPlanetUsingInterfaceProjection {
	PlanetProjection getPlanet(); // fails
}

public interface PlanetProjection {
	String getName();
}

template.query(WithRefs.class).as(ProjectPlanetUsingInterfaceProjection.class) // fails

Related Issue: #3894

christophstrobl avatar Dec 13 '21 09:12 christophstrobl