javaandroidormgreendaogreendao-generator

Greendao can't generate join dao import (ToMany relation)


Greendao not generating import of ToMany joiner dao. How can I do this? I'm creating Book and BookStore, trying save list of books in book store by Custom joiner. After build trying generated Joiner JoinBookStoreWithBookDao not importing in BookStoreDao but exists.

Screenshot

Sources

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;
}

Solution

  • I found reason. Joiner should be inside of package for "parent", he can't be in another package.