blinkfox / fenix

This is an extension library to the Spring Data JPA complex or dynamic SQL query. 这是一个比 MyBatis 更加强大的 Spring Data JPA 扩展库,为解决复杂动态 JPQL (或 SQL) 而生。https://blinkfox.github.io/fenix
https://blinkfox.github.io/fenix
Apache License 2.0
345 stars 72 forks source link

条件生成需要有优先级怎么写 #64

Closed ciazealee closed 2 years ago

ciazealee commented 2 years ago

我想要达到 where a = true and (b = true or b is null)

<trimWhere>
        <andEqual field="a" value="true"/>
        <andIsNull field="b" />
        <orEqual field="b" value="true"/>
</trimWhere>

上面生成的是 where a = true and b = true or b is null,不是想要的效果,有什么办法可以加优先级吗?

blinkfox commented 2 years ago

你在 XML 中是可以写任意 SQL 纯文本的,原本 SQL 是啥样,你就写成啥样就行了,不一定要用语义化标签的,除非动态条件需要。如果需要动态 if /else 判断的,本身也是支持的,用逻辑控制语法 即可,就跟 Mybatis 一样了。

ciazealee commented 2 years ago

明白了