- [NgBatis Docs](https://nebula-contrib.github.io/ngbatis/)
- [NgBatis 文档](https://graph-cn.github.io/ngbatis-docs/)
## 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).
If you prefer JPA, [graph-ocean](https://github.com/nebula-contrib/graph-ocean) is a good choice.
## How it works
See [EXECUTION-PROCESS.md](./EXECUTION-PROCESS.md)
## Requirements
- Springboot
- Maven
- Java 8+
## Version matching
NgBatis | nebula-java | JDK | Springboot | Beetl
---|-------------|---|------------|---
1.3.0 | 3.8.3 | 8 | 2.7.0 | 3.15.10.RELEASE
1.3.0-jdk17 | 3.8.3 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.2 | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
1.2.2-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
### 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.
- Include in your `pom.xml`
- Maven
```xml
org.nebula-contribngbatis1.3.0
```
- Gradle
```groovy
implementation 'org.nebula-contrib:ngbatis:1.3.0'
```
- 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.
- Configure the NebulaGraph Database
Configure `application.yml` with the host and credential to enable access to the NebulaGraph Cluster.
```yml
nebula:
ngbatis:
session-life-length: 300000 # since v1.1.2
check-fixed-rate: 300000 # since v1.1.2
# space name needs to be informed through annotations(@Space) or xml(space="test")
# default false(false: Session pool map will not be initialized)
use-session-pool: false # since v1.1.2
hosts: 127.0.0.1:19669, 127.0.0.1:9669
username: root
password: nebula
space: test
pool-config:
min-conns-size: 0
max-conns-size: 10
timeout: 0
idle-time: 0
interval-idle: -1
wait-time: 0
min-cluster-health-rate: 1.0
enable-ssl: false
```
- Dynamically register beans
```java
@SpringBootApplication(scanBasePackages = { "org.nebula", "your.domain"})
public class YourApplication {
public static void main(String[] args) {
new SpringApplication(YourApplication.class).run(args);
}
}
```
> If SpringCloud is used in your project,
> please use `@ComponentScan( basePackages = {"org.nebula.contrib", "your.domain"} )` instead.
## Examples
### a. The MyBatis fashion(compose nGQL queries)
#### a.1 Declare the data access interface
```java
package ye.weicheng.ngbatis.demo.repository;
import ye.weicheng.ngbatis.demo.pojo.Person;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface TestRepository {
// new features from v1.2.0
Integer returnAge(@Param("person")Person person);
Person selectPerson();
Person selectByPerson(Person person);
List selectAgeGt(Integer age);
List selectListString();
List