Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This source code is licensed under Apache 2.0 License.
## Bug修复

- 修复执行报错时产生连接未回收的泄漏问题
- 修复 ng.include 在多行的情况下,模板无法正常使用的问题

# 2.0.1

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ This source code is licensed under Apache 2.0 License.
## Bugfix

- Fixed connection leak issue when an error occurs during execution.
- Fix the issue where the template fails to function properly when using `ng.include` across multiple lines.

# 2.0.1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ye.weicheng.ngbatis.demo.repository;

import java.util.List;
import java.util.Map;
import org.springframework.data.repository.query.Param;
import ye.weicheng.ngbatis.demo.pojo.Person;

Expand All @@ -12,4 +14,6 @@ public interface NgqlIncludeDao {
Integer testInclude(@Param("myInt") Integer myInt);

Integer returnAge(@Param("person")Person person);

List<Map> selectByFilter(@Param("person") Person person);
}
14 changes: 14 additions & 0 deletions ngbatis-demo/src/main/resources/mapper/NgqlIncludeDao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,18 @@
RETURN @ng.include('include-test-value',{'myInt':age});
</nGQL>


<nGQL id="filterStart">
MATCH (n: person)-[r]->(n2: person)
@if ( isNotEmpty( person.name ) ) {
WHERE id(n) == '${person.name}'
@}
</nGQL>

<select id="selectByFilter" resultType="java.util.Map">
@ng.include('filterStart');
RETURN n as startNode, r as `edge`, n2 as endNode
LIMIT 10
</select>

</mapper>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package ye.weicheng.ngbatis.demo.repository;

import com.alibaba.fastjson.JSON;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -26,5 +29,15 @@ public void test() {
System.out.println("nGQL跨mapper引用测试:" + ngqlInclude4diffMapperDao.testInclude(1));

}

@Test
public void testFilter() {
Person person = new Person();
List<Map> ngTriplet = ngqlIncludeDao.selectByFilter(person);
System.out.println(JSON.toJSONString(ngTriplet));
person.setName("赵小洋");
ngTriplet = ngqlIncludeDao.selectByFilter(person);
System.out.println(JSON.toJSONString(ngTriplet));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected MethodModel parseMethodModel(Node node) {
* @return
*/
protected NgqlModel parseNgqlModel(Element ngqlEl) {
return new NgqlModel(ngqlEl.id(),ngqlEl.text());
return new NgqlModel(ngqlEl.id(),ngqlEl.wholeText());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class NgTriplet<I> {
private Object edge;
private Object endNode;

public NgTriplet() {}

public NgTriplet(Object startNode, Object edge, Object endNode) {
this.startNode = startNode;
this.edge = edge;
Expand Down
Loading