0

Greendao 不生成 ToMany joiner dao 的导入。我怎样才能做到这一点?我正在创建 Book 和 BookStore,尝试通过自定义加入者在书店中保存书籍列表。构建后尝试生成的 Joiner JoinBookStoreWithBookDao 没有导入 BookStoreDao 但存在。

截屏

来源

图书.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() {
   }
}

书店.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;
}
4

1 回答 1

1

我找到了理由。Joiner 应该在“父母”的包内,他不能在另一个包中。

于 2016-11-04T10:02:01.930 回答