Skip to content

Commit

Permalink
Merge pull request #319 from n3A87/ORM2OGM
Browse files Browse the repository at this point in the history
feat:support query directly by entity
  • Loading branch information
knqiufan authored Oct 29, 2024
2 parents 22ebd69 + 1d4e1cb commit 0e417f0
Show file tree
Hide file tree
Showing 23 changed files with 1,872 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package ye.weicheng.ngbatis.demo.pojo.edge;

// Copyright (c) 2022 All project authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

import javax.persistence.Id;
import org.nebula.contrib.ngbatis.annotations.DstId;
import org.nebula.contrib.ngbatis.annotations.SrcId;
import org.nebula.contrib.ngbatis.annotations.base.EdgeType;
import org.nebula.contrib.ngbatis.base.GraphBaseEdge;

/**
* Follow边实体示例
* @author xYLiuuuuuu
* @since 2024/9/11
*/

@EdgeType(name = "follow")
public class Follow extends GraphBaseEdge {

@Id // 可选,如果两个节点之间同一类型边的唯一性由源节点id和目标节点id共同决定,可以不加当前属性
public Long rank;

@SrcId // 可选,如果不需要获取关系的源节点id,可以不加当前属性
public String srcId;

@DstId // 可选,如果不需要获取关系的目标节点id,可以不加当前属性
public String dstId;

public int degree;

public Long getRank() {
return rank;
}

public void setRank(Long rank) {
this.rank = rank;
}

public String getSrcId() {
return srcId;
}

public void setSrcId(String srcId) {
this.srcId = srcId;
}

public String getDstId() {
return dstId;
}

public void setDstId(String dstId) {
this.dstId = dstId;
}

public int getDegree() {
return degree;
}

public void setDegree(int degree) {
this.degree = degree;
}

@Override
public String toString() {
return "Follow{"
+ "rank=" + rank
+ ", srcId='" + srcId + '\''
+ ", dstId='" + dstId + '\''
+ ", degree=" + degree
+ '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package ye.weicheng.ngbatis.demo.pojo.edge;

// Copyright (c) 2022 All project authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

import javax.persistence.Column;
import javax.persistence.Id;
import org.nebula.contrib.ngbatis.annotations.DstId;
import org.nebula.contrib.ngbatis.annotations.SrcId;
import org.nebula.contrib.ngbatis.annotations.base.EdgeType;
import org.nebula.contrib.ngbatis.base.GraphBaseEdge;

/**
* Serve边实体示例
* @author xYLiuuuuuu
* @since 2024/9/11
*/
@EdgeType(name = "serve")
public class Serve extends GraphBaseEdge {

@Id // 可选,如果两个节点之间同一类型边的唯一性由源节点id和目标节点id共同决定,可以不加当前属性
private Long rank;

@SrcId // 可选,如果不需要获取关系的源节点id,可以不加当前属性
private String srcId;

@DstId // 可选,如果不需要获取关系的目标节点id,可以不加当前属性
private String dstId;

@Column(name = "start_year")
private Integer startYear;
@Column(name = "end_year")
private Integer endYear;

public Long getRank() {
return rank;
}

public void setRank(Long rank) {
this.rank = rank;
}

public String getSrcId() {
return srcId;
}

public void setSrcId(String srcId) {
this.srcId = srcId;
}

public String getDstId() {
return dstId;
}

public void setDstId(String dstId) {
this.dstId = dstId;
}

public Integer getStartYear() {
return startYear;
}

public void setStartYear(Integer startYear) {
this.startYear = startYear;
}

public Integer getEndYear() {
return endYear;
}

public void setEndYear(Integer endYear) {
this.endYear = endYear;
}

@Override
public String toString() {
return "Serve{"
+ "rank=" + rank
+ ", srcId='" + srcId + '\''
+ ", dstId='" + dstId + '\''
+ ", startYear=" + startYear
+ ", endYear=" + endYear
+ '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package ye.weicheng.ngbatis.demo.pojo.vertex;

// Copyright (c) 2022 All project authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

import org.nebula.contrib.ngbatis.annotations.base.GraphId;
import org.nebula.contrib.ngbatis.annotations.base.Tag;
import org.nebula.contrib.ngbatis.base.GraphBaseVertex;
import org.nebula.contrib.ngbatis.enums.IdType;


/**
* Player点实体示例
* @author xYLiuuuuuu
* @since 2024/9/11
*/

@Tag(name = "player")
public class Player extends GraphBaseVertex {

@GraphId(type = IdType.STRING)
private String id;

private String name;

private Integer age;

String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

Integer getAge() {
return age;
}

public void setAge(Integer age) {
this.age = age;
}

@Override
public String toString() {
return "Player{"
+ "id='" + id + '\''
+ ", name='" + name + '\''
+ ", age=" + age
+ '}';
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ye.weicheng.ngbatis.demo.pojo.vertex;

// Copyright (c) 2022 All project authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

import org.nebula.contrib.ngbatis.annotations.base.GraphId;
import org.nebula.contrib.ngbatis.annotations.base.Tag;
import org.nebula.contrib.ngbatis.base.GraphBaseVertex;
import org.nebula.contrib.ngbatis.enums.IdType;


/**
* Team点实体示例
* @author xYLiuuuuuu
* @since 2024/9/11
*/

@Tag(name = "team")
public class Team extends GraphBaseVertex {

@GraphId(type = IdType.STRING)
private String id;

private String name;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public String toString() {
return "Team{" + "name='" + name + '\'' + '}';
}
}
Loading

0 comments on commit 0e417f0

Please sign in to comment.