2
我有以下数据模型:适用于应用引擎加入的任何解决方案?
class StadiumOccupant {
String stadiumname;
String username;
}
class Friend {
String username;
String friendname;
}
我想找到的所有用户,在体育场,同时也是我的朋友。我可以这样做:
List<String> friendsAtStadium;
String stadiumId = 'xyz';
List<Friend> friends = select from Friend where username = 'me';
for (Friend friend : friends) {
List<StadiumOccupant> friendAtStadium =
select from StadiumOccupant where
stadiumname = stadiumId and
username = friend.friendname;
friendsAtStadium.addAll(friendAtStadium);
}
这可以使用非常少量的对象。只要用户拥有一小撮朋友,这将无法工作。在应用程序引擎上是否有解决方案?我想不出一个表现好的人。
感谢
--------一些样本数据--------
Friend { john, tim }
Friend { john, mary }
Friend { mary, frank }
StadiumOccupant { abc, tim }
StadiumOccupant { abc, frank }
StadiumOccupant { abc, kim }
,所以如果我是用户 '约翰',我的朋友们:{恬, 玛丽 }。 如果我使用stadiumname ='abc'来运行体育场查询,我应该返回{tim}。
您是否允许更改数据建模? – 2010-08-11 18:23:15
'username = friend.getUsername();'< - 不应该是'username = friend.getFriendName();',因为'friend.getUserName()'将永远是“我”,因为'friend'是一个元素你之前通过用'username =“me”'过滤选择的'friends'? – 2010-08-11 18:28:54
@爱德华:是的,我可以改变建模,我试图找出是否有任何可能的方式来做到这一点,可以任何方式。 – user246114 2010-08-11 18:34:52