在OrientDB中的事务图中添加带有框架的类型化顶点

时间:2015-02-04 15:59:40

标签: java orientdb vertex transactional tinkerpop

早上好,

我正在尝试在事务模式下使用orientDB图,但我不知道为什么,但我的所有Verteces都没有保存,而是在创建时设置的代理类的类型。

这是我的代码:

FramedGraphFactory framedFactory = new FramedGraphFactory();
OrientGraph instance = graphFactory.getTx();
FramedTransactionalGraph<OrientGraph> framedGraph=framedFactory.create(instance);

(GraphFactory通过Spring注入)

SocialUser social = getGraph().addVertex(UUID.randomUUID(), SocialUser.class);
    social.setSocialId(lr.getSocialId() + "_" + lr.getSocial());
    social.setCreationDate(new Date());
    social.setLastLopginDate(new Date());
    social.setUserInfo(lr.getInfo());
    OrientVertex socialV = (OrientVertex) social.asVertex();
    socialV.save();
    getGraph().commit();

(getGraph是我班级中返回FramedTransactionalGraph的方法。)

SocialUser界面

public interface SocialUser extends VertexFrame {

@Property("socialId")
void setSocialId(String socialId);

@Property("socialId")
String getSocialId();

@Property("valid")
void setValid(boolean valid);

@Property("valid")
boolean getValid();

@Property("creationDate")
void setCreationDate(Date creationDate);

@Property("creationDate")
Date getCreationDate();

@Property("lastLoginDate")
void setLastLopginDate(Date lastLoginDate);

@Property("lastLoginDate")
Date getLastLoginDate();

@Property("status")
void setStatus(String status);

@Property("status")
String getStatus();

@Property("info")
public void setUserInfo(Map<String, String> userInfo);

@Property("info")
public Map<String, String> getUserInfo();

@Adjacency(label = "usersEdge", direction = Direction.BOTH)
PhysicUser getPhysicUser();

@Adjacency(label = "usersEdge", direction = Direction.BOTH)
void setPhysicUser(PhysicUser physicUser);

@Adjacency(label = "userUvi", direction = Direction.BOTH)
public Iterable<Uvis> getUvis();

@Adjacency(label = "userUvi", direction = Direction.BOTH)
public void setUvis(Uvis uvis);

@Property("uvi")
public String getCurrentUvi();

@Property("uvi")
public void setCurrentUvi(String uvi);

}

当我在db中检查已保存的内容时,我的所有顶点都存储在OrientDB的V类中。

有人可以帮我吗?

提前谢谢

的问候,斯特凡诺

1 个答案:

答案 0 :(得分:1)

不幸的是,Frames没有将Java类绑定到OrientDB类,因为TinkerPop Blueprints 2.x中没有这个概念。

出于这个原因,OrientDB使用id来读取类类型,因为它是传播到底层Graph实现的唯一参数。尝试做:

SocialUser social = getGraph().addVertex("class:SocialUser,"+UUID.randomUUID(), SocialUser.class);