我想使用子类,但是与此有关。该文档没有明确说明如何使用子类检索解析服务器上可用的所有数据类型。
这是我的 objOwnFeeds :
@ParseClassName(ParseIdentifier.ownFeedsClass)
public class objOwnFeeds extends ParseObject {
//starter fields
public String getObjectId() {
return getString(ParseIdentifier.getObjectIdField());
}
public ParseACL getAcl() {
return getACL();
}
public void setAcl(ParseACL acl) {
setACL(acl);
}
public Date getCreatedAt() {
return getCreatedAt();
}
public void setCreatedAt(Date date) {
setCreatedAt(date);
}
//extended fields
//Strings
public String getOwnerId() {
return getString(ParseIdentifier.getOwnerId());
}
public String getUserInfoId() {return getString(ParseIdentifier.getUserInfoId());}
public String getFeedId() {return getString(ParseIdentifier.getFeedId());}
public String getType() {return getString(ParseIdentifier.getType());}
//Booleans
public Boolean isCreatedByMe() {return getBoolean(ParseIdentifier.getCreatedByMe());}
public Boolean canNotification() {return getBoolean(ParseIdentifier.getCanNotification());}
public Boolean isLikedByMe() {return getBoolean(ParseIdentifier.getLikedByMe());}
public Boolean isFollowedByMe() {return getBoolean(ParseIdentifier.getFollowedByMe());}
//Parse Objects { the problem is here!}
public objFeed getFeed() {return (objFeed) getParseObject(ParseIdentifier.getFeed());}
//numbers
public int getIntervalNotification() {return getInt(ParseIdentifier.getIntervalNotification());}
public long getLastNotificationSent() {return getLong(ParseIdentifier.getLastNotificationSent());}
}
寻找 getFeed() <=此函数需要检索的对象是这个对象:
@ParseClassName(ParseIdentifier.feedsClass)
public class objFeed extends ParseObject {
public String getObjectId() {
return getString(ParseIdentifier.getObjectIdField());
}
public String getNome() {
return getString(ParseIdentifier.nomeFeedField);
}
public void setNome(String nome) {
put(ParseIdentifier.nomeFeedField, nome);
}
public String getNomeToLowerCase() {
return getString(ParseIdentifier.nomeToLowerCaseFeedField);
}
public void setNomeToLowerCase(String nomeToLowerCase) {
put(ParseIdentifier.nomeToLowerCaseFeedField, nomeToLowerCase);
}
public String getUsers() {
return getString(ParseIdentifier.usersFeedField);
}
public void setUsers(String users) {
put(ParseIdentifier.usersFeedField, users);
}
public int getTotalLikes() {
return getInt(ParseIdentifier.totalLikesFeedField);
}
public void setTotalLikes(int totalLikes) {
put(ParseIdentifier.totalLikesFeedField, totalLikes);
}
public int getgetRankPosition() {
return getInt(ParseIdentifier.rankPosition);
}
public void setRankPosition(int rankPosition) {
put(ParseIdentifier.rankPosition, rankPosition);
}
public int getTotalFollowers() {
return getInt(ParseIdentifier.totalFollowersFeedField);
}
public void setTotalFollowers(int totalFollowers) {
put(ParseIdentifier.totalFollowersFeedField, totalFollowers);
}
public ParseACL getAcl() {
return getACL();
}
public void setAcl(ParseACL acl) {
setACL(acl);
}
public String getUserId() {
return getString(ParseIdentifier.userIdFeedField);
}
public void setUserId(String userId) {
put(ParseIdentifier.userIdFeedField, userId);
}
public Date getCreatedAt() {
return getCreatedAt();
}
public void setCreatedAt(Date date) {
setCreatedAt(date);
}
public String getUrlFeed() {
return getString(ParseIdentifier.urlFeedFeedField);
}
public void setUrlFeed(String urlFeed) {
put(ParseIdentifier.urlFeedFeedField, urlFeed);
}
public ParseUser getCreatedBy() {
return getParseUser(ParseIdentifier.createdByField);
}
public void setCreatedBy(ParseUser user) {
put(ParseIdentifier.createdByField, user);
}
}
您可以在此处查看如何查看这些对象:此图像引用了 objOwnFeeds
我也有。
ParseObject.registerSubclass(objFeed.class);
ParseObject.registerSubclass(objOwnFeeds.class);
这是我的查询
ParseQuery query = new ParseQuery(objOwnFeeds.class);
query.include("Feed");
query.findInBackground(new FindCallback<objOwnFeeds>() {
@Override
public void done(List<objOwnFeeds> objects, ParseException e) {
if (e == null){
for (objOwnFeeds obj : objects) {
Log.i("xxxzdae", "done: " + obj.getFeed().getObjectId());
}
}
}
});
但 getFeed()始终返回null。 谢谢您的关注。
答案 0 :(得分:0)
public objFeed getFeed() { return ParseObject.createWithoutData(objFeed.class, getParseObject(ParseIdentifier.getFeed()).getObjectId(); }
在从其中检索任何数据之前,请不要忘记调用object.fetchIfNeeded()
。