0
學習GAE我得到了一些問題。我想將我的用戶的聯繫人列表保存在數據庫中。我使用addUser()來添加新用戶,它的工作原理。但是,當我刷新頁面的列表是空的(非空)。在GAE「數據存儲查看器」中,「列表」字段爲空,但在應用程序中存在。GAE收藏問題
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class ContactList implements IUserList {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
protected List<Key> list;
@Persistent(mappedBy = "contactList")
private User user;
public Key getKey(){
return this.key;
}
public User getUser() {
return user;
}
public ContactList(User user) {
this.list = new ArrayList<Key>(); //this line invoice one only
}
@Override
public Boolean addUser(User user) {
if(this.list.contains(user.getKey())){
return false;
}else{
this.list.add(user.getKey());
return true;
}
}
@Override
public boolean containsKey(Long id) {
return false; //this.list.containsKey(id);
}
@Override
public User get(Long id) {
return null;// this.list.get(id);
}
@Override
public void removeUser(User user) {
this.list.remove(user.getKey());
}
@Override
public int size() {
return this.list.size();
}
@Override
public List<User> users() {
ArrayList<User> users = new ArrayList<User>();
for(Key key : this.list) {
User user = UserManager.getInstance().getUser(key);
users.add(user);
}
return users;
}
@Override
public void addEvent(IEvent event) {
for(User user : this.users()) {
user.addEvent(event);
}
}
@Override
public void clearEvents() {
}
@Override
public ArrayList<IEvent> getEvents() {
return null;
}
}
我想過這個。但我正在使用'detachable =「true」'。我有手動嗎? – 2010-08-06 11:33:42
@柴油:是的... – jsight 2010-08-06 15:42:19