开发者

JPA/Hibernate and messed up named parameters

My simple query looks like this on JPQL:

SELECT COUNT(r) FROM 开发者_如何学Goorg.domain.Resource r WHERE r._parent = :parent AND r._metadata[:metadataKey] is not null

But Hibernate SQL output looks like this (both for H2 and MySQL):

select
            count(resource0_.id) as col_0_0_ 
        from
            resources resource0_,
            resource_metadata metadata1_ 
        where
            resource0_.id=metadata1_.resource_id 
            and metadata1_.datum_key = ? 
            and resource0_.parent_id=? 
            and (
                metadata1_.datum_value is not null
            ) limit ?

The problem here is the known bug in Hibernate which messes up prepared statement parameters. So in my case parent and key are mixed.

Any suggestions for a work around apart from native query?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜