我正在尝试为我的Spring数据jpa存储库添加多租户支持.我想为每个请求动态设置租户ID,但它不适用于存储库上的自定义查找器findBy*方法.我遵循了这个指南:http://codecrafters.blogspot.sk/2013/03/multi-tenant-cloud-applications-with.html
我的存储库看起来像这样:
public interface CountryRepository extends PagingAndSortingRepository<Country, Long> {
Country findByName(String name);
Country findByIsoCountryCode(String isoCountryCode);
}
Run Code Online (Sandbox Code Playgroud)
当我在存储库接口上调用任何自定义finder findBy*方法时,我收到以下错误:
javax.persistence.PersistenceException: Exception [EclipseLink-6174] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: No value was provided for the session property [eclipselink.tenant-id]. This exception is possible when using additional criteria or tenant discriminator columns without specifying the associated contextual property. These properties must be set through Entity Manager, Entity Manager Factory or persistence unit properties. If …Run Code Online (Sandbox Code Playgroud)