Skip to content

Commit

Permalink
Merge branch 'master' into for-jdk17
Browse files Browse the repository at this point in the history
# Resolved Conflicts:
#	CHANGELOG.md
#	README-CN.md
#	README.md
#	ngbatis-demo/pom.xml
#	pom.xml
  • Loading branch information
CorvusYe committed May 6, 2024
2 parents 267c49c + 7fb441f commit fdb8cec
Show file tree
Hide file tree
Showing 20 changed files with 357 additions and 81 deletions.
32 changes: 30 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,37 @@ This source code is licensed under Apache 2.0 License.
- [ ] Geography
- [x] Duration

# 1.2.0-jdk17-snapshot
## Dependencies upgrade

- [x] Springboot 3.x support. (lastest-jdk17)

# 1.2.2

## Bugfix

- fix: complete the error code of ResultSet into QueryException.
- fix: the issue of not being able to handle Set type.
- fix: the issue of the ranking value of the edge object cannot be filled.
- fix: when the field is aliased by `@Column`, the param name is incorrect. (multi tags support)
- selectBySelective
- selectIdBySelective
- selectBySelectiveStringLike
- selectIdBySelectiveStringLike
- fix: unable to read the correct value of id, the value of the subclass' id is used now. (multi tag scene)
- fix: do not generate asg debug when the log level is not debug, now.

## Develop behavior change

- No longer verifying the number of `@Id` in the entity, please keep the number to 1 on your own.
> 不再对实体中的`@Id`个数进行校验,请注意保持个数为1 (含父类)
# 1.2.1

## Bugfix

- fix: set the specified space in the original method to the proxy method for paging. ([#282](https://github.com/nebula-contrib/ngbatis/pull/282))

- [x] Springboot 3.x support.
# 1.2.0

## Dependencies upgrade

Expand Down
30 changes: 21 additions & 9 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ Copyright (c) 2022 All project authors and nebula-contrib. All rights reserved.
This source code is licensed under Apache 2.0 License.
-->

# NGBATIS
# NgBatis

<p align="center">
<br> <a href="README.md">English</a> | 中文
</p>

- [Ngbatis Docs](https://nebula-contrib.github.io/ngbatis/)
- [Ngbatis 文档](https://corvusye.github.io/ngbatis-docs/)
- [NgBatis Docs](https://nebula-contrib.github.io/ngbatis/)
- [NgBatis 文档](https://graph-cn.github.io/ngbatis-docs/)

## NGBATIS是什么?

**NGBATIS** 是一款针对 [Nebula Graph](https://github.com/vesoft-inc/nebula) + Springboot 的数据库 ORM 框架。借鉴于 [MyBatis](https://github.com/mybatis/mybatis-3) 的使用习惯进行开发。包含了一些类似于[mybatis-plus](https://github.com/baomidou/mybatis-plus)的单表操作,另外还有一些图特有的实体-关系基本操作。
**NgBatis** 是一款针对 [Nebula Graph](https://github.com/vesoft-inc/nebula) + Springboot 的数据库 ORM 框架。借鉴于 [MyBatis](https://github.com/mybatis/mybatis-3) 的使用习惯进行开发。包含了一些类似于[mybatis-plus](https://github.com/baomidou/mybatis-plus)的单表操作,另外还有一些图特有的实体-关系基本操作。
如果使用上更习惯于JPA的方式,[graph-ocean](https://github.com/nebula-contrib/graph-ocean) 是个不错的选择。

## NGBATIS 是怎么运行的?
## NgBatis 是怎么运行的?

请看设计文档 [EXECUTION-PROCESS.md](./EXECUTION-PROCESS.md)

Expand All @@ -33,13 +33,25 @@ This source code is licensed under Apache 2.0 License.

NgBatis | nebula-java | JDK | Springboot | Beetl
---|-------------|---|------------|---
1.2.0-jdk17-SNAPSHOT | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.0-SNAPSHOT | 3.6.0 | 8 | 2.7.0 | 3.1.8.RELEASE
1.2.2 | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
1.2.1-jdk17 | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.1 | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
1.2.0-jdk17 | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.0 | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
1.1.5 | 3.5.0 | 8 | 2.7.0 | 3.1.8.RELEASE
1.1.4 | 3.5.0 | 8 | 2.7.0 | 3.1.8.RELEASE
1.1.3 | 3.5.0 | 8 | 2.7.0 | 3.1.8.RELEASE
1.1.2 | 3.4.0 | 8 | 2.7.0 | 3.1.8.RELEASE

### 快照版

NgBatis | nebula-java | JDK | Springboot | Beetl
---|-------------|---|------------|---
1.2.2-jdk17-SNAPSHOT | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.2-SNAPSHOT | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE

> 在同版本号快照版中,依赖的第三方可能会随时升级
## 如何使用(可在克隆代码后,参考 ngbatis-demo 项目)

### 在项目引入
Expand All @@ -65,14 +77,14 @@ This source code is licensed under Apache 2.0 License.
<dependency>
<groupId>org.nebula-contrib</groupId>
<artifactId>ngbatis</artifactId>
<version>1.2.0-jdk17-SNAPSHOT</version>
<version>1.2.2</version>
</dependency>
```

- Gradle

```groovy
implementation 'org.nebula-contrib:ngbatis:1.2.0'
implementation 'org.nebula-contrib:ngbatis:1.2.1'
```

### 参考 [【ngbatis-demo】](./ngbatis-demo),与springboot无缝集成。在该项目的 test 中还有api的样例。在开发过程中每增加一个特性也都会同步更新ngbatis-demo的用例
Expand Down
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ Copyright (c) 2022 All project authors and nebula-contrib. All rights reserved.
This source code is licensed under Apache 2.0 License.
-->

# NGBATIS
# NgBatis

<p align="center">
<br> English | <a href="README-CN.md">中文</a>
</p>

- [Ngbatis Docs](https://nebula-contrib.github.io/ngbatis/)
- [Ngbatis 文档](https://graph-cn.github.io/ngbatis-docs/)
- [NgBatis Docs](https://nebula-contrib.github.io/ngbatis/)
- [NgBatis 文档](https://graph-cn.github.io/ngbatis-docs/)

## What is NGBATIS
## What is NgBatis

**NGBATIS** is a database ORM framework base [NebulaGraph](https://github.com/vesoft-inc/nebula) + spring-boot, which takes advantage of the [mybatis’](https://github.com/mybatis/mybatis-3) fashion development, including some de-factor operations in single table and vertex-edge, like [mybatis-plus](https://github.com/baomidou/mybatis-plus).
**NgBatis** is a database ORM framework base [NebulaGraph](https://github.com/vesoft-inc/nebula) + spring-boot, which takes advantage of the [mybatis’](https://github.com/mybatis/mybatis-3) fashion development, including some de-factor operations in single table and vertex-edge, like [mybatis-plus](https://github.com/baomidou/mybatis-plus).

If you prefer JPA, [graph-ocean](https://github.com/nebula-contrib/graph-ocean) is a good choice.

Expand All @@ -34,13 +34,26 @@ See [EXECUTION-PROCESS.md](./EXECUTION-PROCESS.md)

NgBatis | nebula-java | JDK | Springboot | Beetl
---|-------------|---|------------|---
1.2.0-jdk17-SNAPSHOT | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.0-SNAPSHOT | 3.6.0 | 8 | 2.7.0 | 3.1.8.RELEASE
1.2.2-jdk17 | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.2 | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
1.2.1-jdk17 | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.1 | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
1.2.0-jdk17 | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.0 | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
1.1.5 | 3.5.0 | 8 | 2.7.0 | 3.1.8.RELEASE
1.1.4 | 3.5.0 | 8 | 2.7.0 | 3.1.8.RELEASE
1.1.3 | 3.5.0 | 8 | 2.7.0 | 3.1.8.RELEASE
1.1.2 | 3.4.0 | 8 | 2.7.0 | 3.1.8.RELEASE

### SNAPSHOT

NgBatis | nebula-java | JDK | Springboot | Beetl
---|-------------|---|------------|---
1.2.2-jdk17-SNAPSHOT | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.2-SNAPSHOT | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE

> The third-party dependencies may differ within the same snapshot version.
## How to use

> You could refer to ngbatis-demo in this repo.
Expand All @@ -67,14 +80,14 @@ See [EXECUTION-PROCESS.md](./EXECUTION-PROCESS.md)
<dependency>
<groupId>org.nebula-contrib</groupId>
<artifactId>ngbatis</artifactId>
<version>1.2.0-jdk17-SNAPSHOT</version>
<version>1.2.2-jdk17</version>
</dependency>
```

- Gradle

```groovy
implementation 'org.nebula-contrib:ngbatis:1.2.0-jdk17-SNAPSHOT'
implementation 'org.nebula-contrib:ngbatis:1.2.2-jdk17'
```

- Referring to [ngbatis-demo](./ngbatis-demo), which was smoothly integrated with spring-boot. The API examples could be found under the test of it for all features of ngbatis.
Expand Down
2 changes: 1 addition & 1 deletion ngbatis-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>org.nebula-contrib</groupId>
<artifactId>ngbatis</artifactId>
<version>1.2.0-jdk17</version>
<version>1.2.2-jdk17</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public interface TestRepository extends NebulaDaoBasic<Person, String> {
void insertDynamic(List<DynamicNode> list);

Boolean spaceFromParam(@Param("specifySpace") String specifySpace);


List<Person> dynamicSpaceWithPage(Page<Person> page, @Param("space") String space);

NgSubgraph<String> resultContainingSet();

class DynamicNode {
@Id
private String vid;
Expand Down
13 changes: 13 additions & 0 deletions ngbatis-demo/src/main/resources/mapper/TestRepository.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@
<select id="spaceFromParam" space="${specifySpace}" spaceFromParam="true">
RETURN true;
</select>

<select id="dynamicSpaceWithPage" space="${space}" spaceFromParam="true" resultType="ye.weicheng.ngbatis.demo.pojo.Person">
MATCH (n: person)
RETURN n
</select>

<select id="resultContainingSet" resultType="org.nebula.contrib.ngbatis.models.data.NgSubgraph">
GO 1 STEPS FROM "Tom" OVER like REVERSELY
YIELD $^ AS src, EDGE AS destination, $$ AS dst
| YIELD
toSet( collect( $-.dst ) ) AS nodes,
toSet( collect( $-.destination ) ) AS relationships
</select>


</mapper>
Expand Down
13 changes: 8 additions & 5 deletions ngbatis-demo/src/main/resources/testgraph.ngql
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
create space if not exists test (vid_type = fixed_string(32))
:sleep 20
use test
create tag if not exists person(name string,gender string,height double,age int32 ,birthday datetime)
create tag if not exists employee(name string,gender string,height double,age int32 ,birthday datetime,position string)
create edge if not exists like(likeness double)
create tag index person_index_1 on person(age,birthday)
use test;
create tag if not exists person(name string,gender string,height double,age int32 ,birthday datetime);
create tag if not exists employee(name string,gender string,height double,age int32 ,birthday datetime,position string);
create edge if not exists like(likeness double);
create tag index person_index_1 on person(age,birthday);

CREATE tag `column_alias` (`first_name` string NULL , `last_name` string NULL );
CREATE TAG INDEX `i_column_alias_first_name` ON `column_alias`(`first_name`(50));
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ public void spaceFromParam() {
Assert.isTrue(e instanceof QueryException && e.getMessage().contains("SpaceNotFound"));
}
}

@Test
public void dynamicSpaceWithPage() {
String spaceName = "test" + System.currentTimeMillis();
try {
Page<Person> page = new Page<>();
page.setPageSize(3);
page.setPageNo(1);
repository.dynamicSpaceWithPage(page, spaceName);
} catch (Exception e) {
System.out.println(e.getMessage());
Assert.isTrue(e instanceof QueryException && e.getMessage().contains("SpaceNotFound"));
}
}

@Test
public void insertWithTimestamp() {
Expand All @@ -250,5 +264,11 @@ public void insertWithTimestamp() {
person.setBirthday(new Date());
repository.insertWithTimestamp(person);
}

@Test
public void testResultContainingSet() {
NgSubgraph<String> rs = repository.resultContainingSet();
System.out.println(JSON.toJSONString(rs));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
//
// This source code is licensed under Apache 2.0 License.

import java.util.List;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.locationtech.jts.util.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -16,26 +20,97 @@
* <br>Now is history!
*/
@SpringBootTest
@TestMethodOrder(OrderAnnotation.class)
public class ColumnAliasDaoTest {

@Autowired
private ColumnAliasDao dao;
static final String idNo = "ID" + System.currentTimeMillis();
static final String firstName = Math.random() + "";

@Test
public void updateById() {
long now = System.currentTimeMillis();
String idNo = "UBI" + now;
@Order(1)
public void insert() {
ColumnAlias colAliasPojo = new ColumnAlias();
colAliasPojo.setIdNo(idNo);
dao.insert(colAliasPojo);
}

String firstName = Math.random() + "";
@Test
@Order(2)
public void updateById() {
ColumnAlias colAliasPojo = new ColumnAlias();
colAliasPojo.setIdNo(idNo);
colAliasPojo.setFirstName(firstName);
dao.updateById(colAliasPojo);

}

@Test
@Order(3)
public void selectById() {
ColumnAlias colAliasPojoDb = dao.selectById(idNo);

Assert.isTrue(firstName.equals(colAliasPojoDb.getFirstName()));
Assert.isTrue(idNo.equals(colAliasPojoDb.getIdNo()));
}

@Test
@Order(4)
public void selectBySelective() {
ColumnAlias colAliasPojo = new ColumnAlias();
colAliasPojo.setIdNo(idNo);
colAliasPojo.setFirstName(firstName);
List<ColumnAlias> nodesInDb = dao.selectBySelective(colAliasPojo);
Assert.isTrue(nodesInDb.size() > 0);
nodesInDb.forEach(node -> {
Assert.isTrue(node.getFirstName().equals(firstName));
Assert.isTrue(node.getIdNo().equals(idNo));
});
}

@Test
@Order(5)
public void selectIdBySelective() {
ColumnAlias colAliasPojo = new ColumnAlias();
colAliasPojo.setIdNo(idNo);
colAliasPojo.setFirstName(firstName);
List<String> idsInDb = dao.selectIdBySelective(colAliasPojo);
Assert.isTrue(idsInDb.contains(idNo));
}

@Test
@Order(6)
public void selectBySelectiveStringLike() {
ColumnAlias colAliasPojo = new ColumnAlias();
String query = firstName.substring(0, 5);
colAliasPojo.setFirstName(query);
List<ColumnAlias> nodesInDb = dao.selectBySelectiveStringLike(colAliasPojo);
Assert.isTrue(nodesInDb.size() > 0);
nodesInDb.forEach(node -> Assert.isTrue(node.getFirstName().contains(query)));
}

// selectIdBySelectiveStringLike
@Test
@Order(7)
public void selectIdBySelectiveStringLike() {
ColumnAlias colAliasPojo = new ColumnAlias();
colAliasPojo.setIdNo(idNo);
String query = firstName.substring(0, 5);
colAliasPojo.setFirstName(query);
List<String> idsInDb = dao.selectIdBySelectiveStringLike(colAliasPojo);
Assert.isTrue(idsInDb.contains(idNo));
}

@Test
@Order(99)
public void deleteById() {
dao.deleteById(idNo);
}

@Test
@Order(100)
public void selectByIdAfterDelete() {
ColumnAlias colAliasPojoDb = dao.selectById(idNo);
Assert.isTrue(colAliasPojoDb == null);
}

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>ngbatis</name>
<groupId>org.nebula-contrib</groupId>
<artifactId>ngbatis</artifactId>
<version>1.2.0-jdk17</version>
<version>1.2.2-jdk17</version>

<description>
NgBatis is a database ORM framework base NebulaGraph + spring-boot,
Expand Down
Loading

0 comments on commit fdb8cec

Please sign in to comment.