开发者

Retrieve JDO object without certain attribute

开发者 https://www.devze.com 2023-03-30 08:51 出处:网络
I have a class Post and within it I have a list of Reviews. Is it possible to retrieve a Post object without reviewList (or as an empty list)? Or maybe I should use some other model to achieve this.

I have a class Post and within it I have a list of Reviews. Is it possible to retrieve a Post object without reviewList (or as an empty list)? Or maybe I should use some other model to achieve this.

@PersistenceCapable
class Post {
   @PrimaryKey
   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
   long id;

   @Persistent
   String title;

   @Persistent
   Li开发者_开发问答st<Review> reviewList;
}

.

@PersistenceCapable
class Review {
   @PrimaryKey
   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
   long id;

   @Persistent
   String comment;
}


The documentation says:

Accessing a collection performs a query

I read this as: the collection is lazy-loaded. This means that when you load a Post, its reviews are not laoded. They will be loaded automatically when you access the collection (i.e. when calling any method of the collection).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号