nebula-contrib / ngbatis

NGBATIS is a database ORM framework base NebulaGraph + spring-boot, which takes advantage of the mybatis’ fashion development, including some de-factor operations in single table and vertex-edge, like mybatis-plus. NGBATIS 是一款针对 NebulaGraph + Springboot 的数据库 ORM 框架。借鉴于 MyBatis 的使用习惯进行开发。https://graph-cn.github.io/ngbatis-docs/
https://nebula-contrib.github.io/ngbatis/
Apache License 2.0
132 stars 42 forks source link

Does ngbatis support expression of ognl? #153

Closed gavin-ao closed 6 months ago

gavin-ao commented 1 year ago

这种if标签没有用,请问是否支持?如果不支持,有什么办法绕过去吗?谢谢

CorvusYe commented 1 year ago

条件控制的标签可以使用 @if 来控制,#的方式不支持哦

<select id="getGraphDataForTest" resultType="com.vesoft.nebula.client.graph.data.ResultSet">
    MATCH  p1=(v_pl:`linkage_plan`)-[e_pc:`relation`]->(v_c_1:`frame_instance`),
            p2=(v_a_1:`frame_dict`)-[e_ab_1:`relation`{relation_type:20}]->(v_b_1:`biz_frame_instance`),
            p3=(v_d_1:`loc_frame_instance`)-[e_dc_1:`relation`*1..6]->(v_c_1:`frame_instance`)<-[e_bd_1:`relation`*1..6]-(v_b_1:`biz_frame_instance`)
            where 1=1
            @if ( isNotEmpty( structname ) ) {
                and v_c_1.frame_instance.structName = '${structname}'
            @ }
            and ((id(v_pl) contains "${querycontent}") or (id(v_c_1) contains "${querycontent}")
            or (id(v_a_1) contains "${querycontent}") or (id(v_b_1) contains "${querycontent}") or (id(v_d_1) contains "${querycontent}"))
            return nodes(p1), relationships(p1),nodes(p2), relationships(p2),nodes(p3), relationships(p3) limit 100;
</select>
gavin-ao commented 1 year ago

好的,谢谢,我试一下

gavin-ao commented 1 year ago

有效,感谢

CorvusYe commented 1 year ago

可以就行。如果想使用 # 这种类似 preparedStatement 的占位符形式, 可以使用 and v_c_1.frame_instance.structName == {structname}, 但前提是这个参数所在的位置ngql 支持参数化

gavin-ao commented 1 year ago

👌👌