如何检索实体中的列表对象?
How to retrieving a list object in the entity?
我有一个具有 List 对象的实体。我可以看到当前包含一个元素的对象。但是,当我尝试检索列表时,我总是得到 null。
共有三个 classes:两个实体 classes 和一个端点 class
public class Buddy{
...
@Persistent (mappedBy="owner")
@Order (extensions = @Extension(vendorName="datanucleus",key="list-ordering", value="sharedOn desc"))
@Element(dependent = "true")
@JsonManagedReference
private List<Sticky> listOfObjects;
...
public List<Sticky> getStickies(){
return listOfObjects;
}
}
public Class Sticky{
...
@Persistent (dependent="true")
@JsonBackReference
private Buddy owner;
...
public Buddy getBuddy(){
return this.owner;
}
...
}
public class StickyEndpoint{
...
@ApiMethod(name = "createSticky")
public Sticky createSticky(Sticky sticky){
Buddy buddy = sticky.getBuddy(); // confirmed that buddy returned is not null
List<Sticky> sticky = buddy.getStickies(); //sticky always return null
...
return sticky;
}
....
}
有人可以帮忙吗?谢谢!
JDO 不会让您插入自定义类型,所以 List 不会 运行。我最终安装了 Objectify....
我有一个具有 List 对象的实体。我可以看到当前包含一个元素的对象。但是,当我尝试检索列表时,我总是得到 null。
共有三个 classes:两个实体 classes 和一个端点 class
public class Buddy{
...
@Persistent (mappedBy="owner")
@Order (extensions = @Extension(vendorName="datanucleus",key="list-ordering", value="sharedOn desc"))
@Element(dependent = "true")
@JsonManagedReference
private List<Sticky> listOfObjects;
...
public List<Sticky> getStickies(){
return listOfObjects;
}
}
public Class Sticky{
...
@Persistent (dependent="true")
@JsonBackReference
private Buddy owner;
...
public Buddy getBuddy(){
return this.owner;
}
...
}
public class StickyEndpoint{
...
@ApiMethod(name = "createSticky")
public Sticky createSticky(Sticky sticky){
Buddy buddy = sticky.getBuddy(); // confirmed that buddy returned is not null
List<Sticky> sticky = buddy.getStickies(); //sticky always return null
...
return sticky;
}
....
}
有人可以帮忙吗?谢谢!
JDO 不会让您插入自定义类型,所以 List 不会 运行。我最终安装了 Objectify....