私は次のように定義されたモデルを持っている...MongoとPlayフレームワークを使用してハッシュテーブルを保存していますか?
@MongoEntity
public class Ent extends MongoModel{
public Hashtable<Integer, CustomType> fil;
public int ID;
public Ent(){
fil = new Hashtable<Integer, CustomType>();
}
}
CustomType
は、基本的には、(とりわけ)項目のリストを保持している私が作成したデータ型です。私のWebアプリケーションのある時点で、コントローラからハッシュテーブルを更新して、今更新したアイテムのサイズを読み戻します。次のような...
public static void addToHash(CustomType type, int ID, int key){
//First I add an element to the list I'm storing in custom type.
Ent ent = Ent.find("byID",ID).first();
CustomType element = user.fil.get(key);
if(element == null) element = new CustomType();
element.add(type);
ent.save();
//Next I reset the variables and read back the value I just stored..
ent = null;
ent = User.find("byID",ID).first();
element = ent.fil.get(ID);
System.out.println("SIZE = " + element.size()); //null pointer here
}
あなたは、私が要素を追加し、私の上記の例で参照モデルを保存し、その後、私はちょうど追加されていると、それが保存されていないものをリードバックを試みることができたよう。上記のモデルEnt
は、実際に使用しているモデル全体の最小バージョンです。 List
、String
、Integer
などのモデル内の他の値はすべて更新されても正しく更新されますが、このHashtable
は保存していません。なぜこれが起こっているのでしょうか、どうすればそれを修正できますか?