简体   繁体   English

将MariaDB与Hibernate Filter结合使用时,如何获取AssertionFailure'找不到表'的根本原因?

[英]How to get root cause of AssertionFailure 'Table not found' when using MariaDB with Hibernate Filter?

I am using the following test setup for evaluating Hibernate Filter features with various databses: 我正在使用以下测试设置来评估具有各种数据库的Hibernate Filter功能

  • Spring Boot Starter 1.5.3.RELEASE Spring Boot Starter 1.5.3。发布
  • Hibernate 5.2.10.Final 休眠5.2.10.Final
  • Spring Data Envers 1.1.3.RELEASE -> Spring Data JPA 1.11.3.RELEASE Spring Data Envers 1.1.3.RELEASE-> Spring Data JPA 1.11.3.RELEASE
  • mariadb-java-client 1.5.9 mariadb-java-client 1.5.9
  • HikariCP 2.6.1 HikariCP 2.6.1
  • MariaDB 10.1.22 (docker container) MariaDB 10.1.22(docker容器)

The database schema is setup using Flyway and works fine, so the table is there. 数据库架构是使用Flyway设置的,并且可以正常工作,因此该表就在那里。

Now I've got an entity class 'User' with a custom table name and a filter for the active-field: 现在,我有了一个带有自定义表名称和活动字段过滤器的实体类“ User”

@Entity
@Table(name = "\"users\"")
@FilterDef(name = "activeUsers", parameters = @ParamDef(name = "active", type = "boolean"))
@Filter(name = "activeUsers", condition = "\"active\" = :active")
public class User {

    @Id
    private Long id;

    private boolean active;

    // getters/setters (not shown)

}

In addition, a custom repository is provided to allow usage of the filter: 另外,提供了一个自定义存储库以允许使用过滤器:

public interface RepositoryExtended<T> {
     Iterable<T> findAll(boolean active);
}

public class UserRepositoryImpl implements RepositoryExtended<User> {
    @Autowired
    private UserRepository userRepository;

    @Override
    public Iterable<User> findAll(boolean active) {

        EntityManagerHolder holder = (EntityManagerHolder) TransactionSynchronizationManager.getResource(entityManagerFactory);
        EntityManager entityManager = holder.getEntityManager();
        Filter hibernateFilter = entityManager.unwrap(Session.class).enableFilter("activeUsers").setParameter("active", active);
        hibernateFilter.validate();

        Iterable<User> users = userRepository.findAll();
        entityManager.unwrap(Session.class).disableFilter("activeUsers");
        return users;
    }
}

Final the UserRepository based on Spring Data JPA CrudRepository and the custom repository from above: 根据上面的Spring Data JPA CrudRepository和自定义存储库 ,最终完成UserRepository

public interface UserRepository extends CrudRepository<User, Long>, RepositoryExtended<User> {
}

Now the test setup : 现在测试设置

@RunWith(SpringRunner.class)
@Transactional
@Rollback
@ContextConfiguration(classes = { DBConfig.class })
public class UserRepositoryTests {

    @PersistenceContext
    private EntityManager em;
    @Autowired
    UserRepository repository;

    @Before
    public void setUp() {
        user = new User();
        user.setActive(true);
        user = repository.save(user);

        user2 = new User();
        user2.setActive(true);
        user2 = repository.save(user2);

        em.flush();
       em.clear();
    }

@Test
    public void filteredQueries() {

        assertEquals(2, repository.count());
        assertTrue(repository.findAll().iterator().hasNext());

        Iterable<User> findAllActive = repository.findAll(true); // THIS FAILS
        assertTrue(findAllActive.iterator().hasNext());
    }
}

with the JDBC and Hibernate/JPA settings : 使用JDBC和Hibernate / JPA设置

mariadb.db.driver=org.mariadb.jdbc.Driver
mariadb.db.url=jdbc:mariadb://127.0.0.1:3306/PRORK
mariadb.db.username=root
mariadb.db.password=root

hibernate.dialect=org.hibernate.dialect.MariaDB53Dialect
hibernate.globally_quoted_identifiers=true
hibernate.hbm2ddl.auto=validate
hibernate.format_sql=true
hibernate.show_sql=true
hibernate.default_schema=PRORK

Used in bean configuration: 在bean配置中使用:

@Configuration
@EnableTransactionManagement
public class DBConfig {

@Bean(destroyMethod = "close")
public DataSource dataSource(Environment env) {
    HikariConfig dataSourceConfig = new HikariConfig();
    dataSourceConfig.setDriverClassName("org.mariadb.jdbc.Driver");
    dataSourceConfig.setJdbcUrl("jdbc:mariadb://127.0.0.1:3306/PRORK");
    dataSourceConfig.setUsername("root");
    dataSourceConfig.setPassword("root");
    return new HikariDataSource(dataSourceConfig);
}

@Bean
public Properties jpaProperties() {
    Properties jpaProperties = new Properties();
    jpaProperties.put(hibernate.dialect, "org.hibernate.dialect.MariaDB53Dialect");
    jpaProperties.put(hibernate.hbm2ddl.auto,"validate");
    jpaProperties.put(hibernate.show_sql,"true");
    jpaProperties.put(hibernate.format_sql,"true");
    jpaProperties.put(hibernate.globally_quoted_identifiers,"true");
    jpaProperties.put(hibernate.default_schema, "PRORK");
    return jpaProperties;
}

@Bean
LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan("test.prork");
    entityManagerFactoryBean.setJpaProperties(jpaProperties());
    return entityManagerFactoryBean;
}

@Bean
JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory);
    return transactionManager;
}

}

Running the test results in the following stacktrace: 在以下堆栈跟踪中运行测试结果:

org.hibernate.AssertionFailure: Table `PRORK`.`users` not found
    at org.hibernate.persister.entity.AbstractEntityPersister.getTableId(AbstractEntityPersister.java:5231)
    at org.hibernate.internal.DynamicFilterAliasGenerator.getAlias(DynamicFilterAliasGenerator.java:31)
    at org.hibernate.internal.FilterHelper.render(FilterHelper.java:109)
    at org.hibernate.internal.FilterHelper.render(FilterHelper.java:96)
    at org.hibernate.persister.entity.AbstractEntityPersister.filterFragment(AbstractEntityPersister.java:3641)
    at org.hibernate.engine.internal.JoinSequence.toJoinFragment(JoinSequence.java:201)
    at org.hibernate.engine.internal.JoinSequence.toJoinFragment(JoinSequence.java:187)
    at org.hibernate.hql.internal.ast.util.JoinProcessor.addJoinNodes(JoinProcessor.java:164)
    at org.hibernate.hql.internal.ast.util.JoinProcessor.processJoins(JoinProcessor.java:158)
    at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:785)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:677)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:313)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:261)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:266)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:189)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:141)
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
    at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153)
    at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:546)
    at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:655)
    at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:3318)
    at org.hibernate.query.criteria.internal.CriteriaQueryImpl$1.buildCompiledQuery(CriteriaQueryImpl.java:318)
    at org.hibernate.query.criteria.internal.compile.CriteriaCompiler.compile(CriteriaCompiler.java:127)
    at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:3611)
    at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:203)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298)
    at com.sun.proxy.$Proxy116.createQuery(Unknown Source)
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:656)
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:633)
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:329)
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:504)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:489)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy120.findAll(Unknown Source)
    at test.prork.persistence.UserRepositoryImpl.findAll(UserRepositoryImpl.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:504)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:479)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy120.findAll(Unknown Source)
    at test.prork.persistence.AbstractUserRepositoryTests.filteredQueries(AbstractUserRepositoryTests.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:147)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:129)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)

The same test works without problems for H2, PostgreSQL and Oracle DB, only MariaDB fails . 对于H2,PostgreSQL和Oracle DB,相同的测试可以正常工作,只有MariaDB失败 Also note that the findAll() method without Hibernate filter works just fine, the count method as well. 还要注意,没有Hibernate过滤器的findAll()方法也可以正常工作,count方法也可以。 Some other basic CrudRepository method tests not shown work as well for all four database systems. 未显示的其他一些基本CrudRepository方法测试对于所有四个数据库系统也能正常工作。

Am I doing something wrong with my method applying the filter and for the other database systems it just works by accident? 我在应用过滤器的方法上做错了什么,而对于其他数据库系统,它只是偶然地起作用了吗?

Or are there any setup errors or special settings to keep in mind for MariaDB with Hibernate Filters? 还是对于带有Hibernate过滤器的MariaDB,要记住任何设置错误或特殊设置?

There are two problems in the setup/code: 设置/代码中存在两个问题

First MySQL / MariaDB don't have a schema , so remove the 首先, MySQL / MariaDB没有架构 ,因此删除

hibernate.default_schema

setting to get rid of the AssertionFailure as they use catalog and not schema. 设置摆脱AssertionFailure,因为它们使用目录而不是架构。 Should be given by the JDBC connection anyways. 无论如何,应该由JDBC连接给出。 This Hibernate JIRA ticket gave me the necessary hint , although there are more tickets pointing directly/indirectly to this cause. 这张Hibernate JIRA票证给了我必要的提示 ,尽管还有更多票证直接/间接指向此原因。

Second for MariaDB using the filter will still fail (maybe for MySQL as well, did not test it). 其次,对于MariaDB,使用过滤器仍然会失败 (也许对于MySQL来说,也没有测试)。 This is because of the quotes in the Filter condition are in JPA style, but only the hibernate legacy quotes (ie using backtips ) seem to work for now. 这是因为Filter条件中的引号采用JPA样式,但是目前仅休眠的老式引号 (即使用backtips )似乎可以使用。 No quotes at all does not work either. 完全没有引号也不起作用。

The entity now looks like: 现在,该实体看起来像:

@Entity
@Table(name = "\"users\"")
@FilterDef(name = "activeUsers", parameters = @ParamDef(name = "active", type = "boolean"))
@Filter(name = "activeUsers", condition = "`active` = :active")
public class User {

    @Id
    private Long id;

    private boolean active;
    // getters/setters (not shown)
}

A last tip as it helped me identifying the second issue: take a close look at the Hibernate SQL queries generated from HQL, especially regarding quotes etc. 最后一个技巧帮助我确定了第二个问题: 仔细研究从HQL 生成的Hibernate SQL查询 ,尤其是有关引号的信息。


Update: I've opened a ticket in the Hibernate JIRA as it may be a Hibernate (MariaDB dialect) issue. 更新:我已经在Hibernate JIRA中打开了一张票,因为这可能是Hibernate(MariaDB方言)问题。

It is not a bug, the @Filter condition value is an SQL expression that is passed directly to the database. 这不是错误,@ Filter条件值是直接传递到数据库的SQL表达式。

It seems Mariadb supports both type of quotes except when sql_mode = "ANSI_QUOTES" https://mariadb.com/resources/blog/quotes 似乎Mariadb支持两种引号,除非sql_mode =“ ANSI_QUOTES” https://mariadb.com/resources/blog/quotes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM