【问题标题】:Could not build lazy iterator for class of foreign collection member无法为外部集合成员类构建惰性迭代器
【发布时间】:2015-06-30 22:44:56
【问题描述】:

我有一个简单的 master-detail,当我查询 de master 并检查外部成员集合时,抛出异常 java.lang.IllegalStateException: Could not build lazy iterator for class com.example.entity.detail

List<Master> masters = DBHelper.getMasterDao().queryForAll();

此时,master 可以正常检索,但在尝试访问外部成员时会抛出异常。

类定义

public class Master {

    public Master(){

    }

    @DatabaseField(id = true)
    public int Id;

    @DatabaseField(format = "yyyy-MM-dd'T'HH:mm:ss", dataType = DataType.DATE_STRING)
    public Date CreationDate;

    // Reverse navigation
    @ForeignCollectionField(eager = true)
    public Collection<detail> details;
}

public class Detail{

    @DatabaseField(id = true)
    public long Id;
    @DatabaseField
    public int Month;
    @DatabaseField
    public double Price;
    @DatabaseField
    public double Diff;

    @DatabaseField(canBeNull = true, foreign = true)
    public Master master;
}

【问题讨论】:

    标签: java android sqlite ormlite foreign-collection


    【解决方案1】:

    确保您已在 SQL 数据库中创建所有相关表。

    这是我收到此错误时的错误。我只是仔细查看了我的堆栈跟踪并发现了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-29
      • 2011-01-16
      • 1970-01-01
      • 2016-09-13
      • 2014-02-02
      • 1970-01-01
      • 1970-01-01
      • 2014-08-28
      相关资源
      最近更新 更多