Java CriteriaQuery selectDistinct与@EmbeddedId生成的SQL无效

Java CriteriaQuery selectDistinct与@EmbeddedId生成的SQL无效,java,hibernate,composite-primary-key,Java,Hibernate,Composite Primary Key,我有一个CriteriaQuery我正在构建一个需要获取行数的地方,但是当我使用@EmbeddedId定义了一个复合键时,当Hibernate尝试运行SQL时,我从数据库中得到一个错误: 14:35:16,356 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost/127.0.0.1:8080-2) SQL Error: 909, SQLState: 42000 14:35:16,357 ERROR [

我有一个
CriteriaQuery
我正在构建一个需要获取行数的地方,但是当我使用
@EmbeddedId
定义了一个复合键时,当Hibernate尝试运行SQL时,我从数据库中得到一个错误:

14:35:16,356 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost/127.0.0.1:8080-2) SQL Error: 909, SQLState: 42000
14:35:16,357 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost/127.0.0.1:8080-2) ORA-00909: invalid number of arguments
Hibernate生成的SQL类似于下面的SQL,其中嵌入ID的成员位于distinct子句中:

select
    count(distinct tab_.COLUMN_A,
        tab_.COLUMN_B,
        tab_.COLUMN_C) as col_0_0_ 
from
    SOME_TABLE tab_ 
where
    -- ...
我的Java代码的缩短版本是:

CriteriaBuilder builder = entityManager.getCriteriaBuilder();

CriteriaQuery<Long> countQuery = builder.createQuery(Long.class);
Root<SomeEntity> root = query.from(SomeEntity.class);
countQuery.select(builder.countDistinct(root));

// ... then add predicates

long totalRowCount = entityManager.createQuery(countQuery).getSingleResult();
CriteriaBuilder=entityManager.getCriteriaBuilder();
CriteriaQuery countQuery=builder.createQuery(Long.class);
Root=query.from(SomeEntity.class);
countQuery.select(builder.countDistinct(root));
// ... 然后添加谓词
long totalRowCount=entityManager.createQuery(countQuery).getSingleResult();

使用带有@EmbeddedId的实体获取计数是否有其他(正确的)方法?

这似乎是Hibernate中的一个已知问题。