Datanucleus mongodb引用

时间:2015-11-19 09:05:17

标签: mongodb orm datanucleus

我可以通过DBRef获取字段吗? 我必须将收集映射到:

@PersistenceCapable(table = "group")
public class MyGroup
{
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY, column = "_id")
    private String id;
    private String name;
    private Person person;

    // getters/setters
    ...
}

@PersistenceCapable(table = "people")
public class Person
{
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY, column = "_id")
    private String id;
    private String firstName;
    private String lastName;

    // getters/setters
    ...
}

我想得到人名(目前我的人名为null):

MyGroup myGroup = persistenceManager.getObjectById(MyGroup.class, "5230a918ac8c95fd3d9a3dfa")
myGroup.getPerson().getFirstName();

并执行查询:

Query query = persistenceManager.newQuery(MyGroup.class);
query.setFilter("persone.firstName == \"Tester\"");

1 个答案:

答案 0 :(得分:0)

DataNucleus不支持MongoDB数据存储上的DBRef: http://www.datanucleus.org/servlet/forum/viewthread_thread,7924#38188