Postgresql 嵌套异常为org.hibernate.exception.sqlgrammareexception:无法提取结果集

Postgresql 嵌套异常为org.hibernate.exception.sqlgrammareexception:无法提取结果集,postgresql,spring-boot,hibernate,multi-tenant,Postgresql,Spring Boot,Hibernate,Multi Tenant,我在引入基于模式的多租户时遇到了这个错误 在我的代码中。我正在使用SpringBoot、hibernate和postgresql。我有 通过JHipster生成初始代码并尝试添加多个 生成的代码之上的租赁功能。这是我需要的文件 增加** 租户连接提供程序类 @Component public class TenantConnectionProvider implements MultiTenantConnectionProvider { private static Logger lo

我在引入基于模式的多租户时遇到了这个错误 在我的代码中。我正在使用SpringBoot、hibernate和postgresql。我有 通过JHipster生成初始代码并尝试添加多个 生成的代码之上的租赁功能。这是我需要的文件 增加**

租户连接提供程序类

@Component
public class TenantConnectionProvider implements MultiTenantConnectionProvider {

    private static Logger logger = LoggerFactory.getLogger(TenantConnectionProvider.class);
    private String DEFAULT_TENANT = "public";
    private DataSource datasource;

    public TenantConnectionProvider(DataSource dataSource) {
        this.datasource = dataSource;
    }

    @Override
    public Connection getAnyConnection() throws SQLException {
        return datasource.getConnection();
    }

    @Override
    public void releaseAnyConnection(Connection connection) throws SQLException {
        connection.close();
    }

    @Override
    public Connection getConnection(String tenantIdentifier) throws SQLException {
        logger.info("Get connection for tenant {}", tenantIdentifier);
        final Connection connection = getAnyConnection();
        connection.setSchema(tenantIdentifier);
        return connection;
    }

    @Override
    public void releaseConnection(String tenantIdentifier, Connection connection) throws SQLException {
        logger.info("Release connection for tenant {}", tenantIdentifier);
        connection.setSchema(DEFAULT_TENANT);
        releaseAnyConnection(connection);
    }
}

@Component
public class TenantSchemaResolver implements CurrentTenantIdentifierResolver {

    private String defaultTenant ="public";

    @Override
    public String resolveCurrentTenantIdentifier() {
        String t =  TenantContext.getCurrentTenant();
        if(t!=null){
            return t;
        } else {
            return defaultTenant;
        }
    }

    @Override
    public boolean validateExistingCurrentSessions() {
        return true;
    }
}
HibernateConfig

@Configuration
public class HibernateConfig {
    @Autowired
    private JpaProperties jpaProperties;

    @Bean
    JpaVendorAdapter jpaVendorAdapter() {
        return new HibernateJpaVendorAdapter();
    }

    @Bean
    LocalContainerEntityManagerFactoryBean entityManagerFactory(
        DataSource dataSource,
        MultiTenantConnectionProvider multiTenantConnectionProviderImpl,
        CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl
    ) {

        Map<String, Object> jpaPropertiesMap = new HashMap<>(jpaProperties.getProperties());
        jpaPropertiesMap.put(Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
        jpaPropertiesMap.put(Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
        jpaPropertiesMap.put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);

        LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
        em.setDataSource(dataSource);
        em.setPackagesToScan("org.confiz*");
        em.setJpaVendorAdapter(this.jpaVendorAdapter());
        em.setJpaPropertyMap(jpaPropertiesMap);
        return em;
    }
}

租户上下文

public class TenantContext {
    private static ThreadLocal<String> currentTenant = new InheritableThreadLocal<>();

    public static String getCurrentTenant() {
        return currentTenant.get();
    }

    public static void setCurrentTenant(String tenant) {
        currentTenant.set(tenant);
    }

    public static void clear() {
        currentTenant.set(null);
    }
}

公共类租户上下文{
私有静态ThreadLocal currentTenant=新的InheritableThreadLocal();
公共静态字符串getCurrentTenant(){
返回currentTenant.get();
}
公共静态无效setCurrentTenant(字符串租户){
currentTenant.set(租户);
}
公共静态无效清除(){
currentTenant.set(null);
}
}

您能分享完整的stacktrace吗