Closed z8manu8z closed 5 months ago
@z8manu8z thank you for reporting the issue. It seems the FluentQuerySupport
is not using the ProxyProjectionFactory
available via RepositoryFactorySupport#getProjectionFactory()
but creates its own instance. Without the BeanFactory
being present the resolution of projectionHelper fails as a result of that.
The fix unfortunately requires quite a few changes in the current implementation, so I'm afraid there's no easy work around for this at the moment.
@christophstrobl Ok thanks for your investigations ! I can adapt my implementation, no worry about that. Can you show me how I can do ?
But I imagine the fix won't be released soon ... ?
I'm having a problem using a bean in a SPEL
@Value
expression by combining Projections and Specifications.Example project : spring-jpa-projections-specs.zip
In the attached project, a projection returned by a
@Query
works correctly, while a projection returned by JpaSpecificationExecutor.findBy(Specification spec) returns an error during http serialization.CityProjection :
@Value("#{@projectionHelper.fullName(target.name, target.country)}") String getFullName();
In CityServiceImpl line 79 :
CityProjection = this.cityRepository.findByNameAndCountry(name, country);
=> works wellCityProjection = this.cityRepository.findBy(new Specification<City>() { @Override public Predicate toPredicate(Root<City> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) { return null; } }, q -> q.as(CityProjection.class).firstValue());
=> fails with message :
Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: EL1057E: No bean resolver registered in the context to resolve access to bean 'projectionHelper']
How can I solve this ?