【问题标题】:Tinkerpop frame: how to create new VertexTinkerpop 框架:如何创建新的顶点
【发布时间】:2023-03-30 19:21:01
【问题描述】:

我无法使用 Tinkerpop 框架和蓝图(2.6 版)保留新顶点。 我究竟做错了什么?这是我的代码..从无用的部分中清理了一些。 我正在使用 OrientDb 作为 Graph 数据库引擎。

我没有收到任何异常,但是当我查看数据库时,它是空的。 你能注意到为什么吗? 谢谢!

框架实体:

public interface User extends VertexFrame{

@Property("id")
public String getId();
@Property("id")
public void getId(String Id);

@Property("email")
public String getEmail();
@Property("email")
public void setEmail(String email);

@Property("password")
public String getPassword();
@Property("password")
public void getPassword(String providerId);

@Property("firstName")
public String getFirstName();
@Property("firstName")
public void setFirstName(String firstName);
}

用户管理器类:

public class UserManager implements Serializable {
    FramedGraphFactory framedFactory = new FramedGraphFactory();
    OrientGraphFactory graphFactory = new OrientGraphFactory("remote:192.168.50.10:2424/database", "user", "pass");
    OrientGraph instance = graphFactory.getTx();
    FramedGraph<OrientGraph> framedGraph = framedFactory.create(instance);


    User user = framedGraph.addVertex(UUID.randomUUID(), User.class);
    user.setFirstName(profile.getFirstName());
    user.setLastName(profile.getLastName());


    OrientVertex u = (OrientVertex) user.asVertex();
    u.save();
}

【问题讨论】:

    标签: orientdb tinkerpop tinkerpop-blueprint tinkerpop-frames


    【解决方案1】:

    我很确定您需要提交交易。

    您可以尝试使用 FramedTransactionalGraph 吗?

    FramedTransactionalGraph<OrientGraph> framedGraph = framedFactory.create(instance);
    
    ....Code....
    
    framedGraph.commit();
    

    【讨论】:

    • 另外,如果这是一个绿地项目,请查看Totorom。它是 Frames 的精神继承者。 (免责声明我是 Totorom 的开发者)
    • 正确。谢谢! :) 现在的问题是更新顶点转换为带有框架但与数据库分离的实体。你对最佳实践有什么建议吗? stackoverflow.com/questions/26187415/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多