Greendao没有生成ToMany joiner dao的导入。我怎样才能做到这一点? 我正在创建Book和BookStore,尝试通过Custom joiner保存书店中的书籍列表。构建后尝试生成的Joiner JoinBookStoreWithBookDao不在BookStoreDao中导入但存在。
Book.java
package com.example.valery.stackoverflowsample.dao;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;
@Entity
public class Book {
@Id
private long id;
public Book() {
}
}
BookStore.java
package com.example.valery.stackoverflowsample.dao;
import com.example.valery.stackoverflowsample.dao.joiner.DaoSession;
import com.example.valery.stackoverflowsample.dao.joiner.JoinBookStoreWithBook;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.JoinEntity;
import org.greenrobot.greendao.annotation.ToMany;
import java.util.ArrayList;
import java.util.List;
@Entity
public class BookStore {
@Id
private long id;
@ToMany
@JoinEntity(
entity = JoinBookStoreWithBook.class,
sourceProperty = "bookStoreId",
targetProperty = "bookId"
)
private List<Book> mBooks;
}
JoinBookStoreWithBook.java
package com.example.valery.stackoverflowsample.dao.joiner;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;
@Entity
public class JoinBookStoreWithBook {
@Id
private long id;
private long bookId;
private long bookStoreId;
}
答案 0 :(得分:1)
我找到了理由。 Joiner应该在包装内为“父母”,他不能在另一个包中。