2012-04-24 14 views
1

を持続しますか? 私はこのしようとしています:は、私は、これらのクラスを持って双方向の関係ormlite

allegationContentDao = getAllegationContentDao(); 
    AllegationContent allegationContent = new AllegationContent(); 
    allegationContent.setContent("allegation content");  
    allegationContentDao.create(allegationContent); 

    allegationItemDao = getAllegationItemDao(); 
    AllegationItem allegationItem = new AllegationItem(); 
    AllegationContent allegationContent2 = allegationContentDao.queryForSameId(allegationContent); //is that wrong? 
    allegationItem.getAllegationContent().add(allegationContent2); 
    allegationItemDao.create(allegationItem); 

が、私はこのエラーを得た:

04-24 10:41:57.128: ERROR/AndroidRuntime(802): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.project/br.com.project.DaoTestActivity}: java.lang.NullPointerException

+0

NPEはどのような行ですか?その行のどのオブジェクトがnullであるかを調べるためにコードをデバッグしようとしましたか?あなたのコードでどこにあなたのヌルポインタにアクセスしようとしているのかを誰にでも分かるための十分な情報はありません。 – Gray

+0

私は行を見つけることができません。私はAllegationItemからForeignCollectionを削除し、AllegationItemを1つ作成してみると、「INFO/Database(1024):sqliteが返されました:エラーコード= 1、msg =近く」) ":"構文 " 私は理解できません。 AllegationItemにはフィールドIDのみがあります。 – Munir

+0

ご迷惑をおかけして申し訳ございません。 – Gray

答えて

1

私は解決しました。テーブルは作成できません。なぜなら、アトリビュートがなく、idだけです(別の問題は何ですか)。 NPEはgetAllegationContentがnullを返すので発生します。まず、setAllegationContentを使用して設定してから取得するForeignCollectionリストを作成する必要があります。

関連する問題