我可以通过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\"");
答案 0 :(得分:0)
DataNucleus不支持MongoDB数据存储上的DBRef: http://www.datanucleus.org/servlet/forum/viewthread_thread,7924#38188