objectbox / objectbox-java

Android Database - first and fast, lightweight on-device vector database
https://objectbox.io
Apache License 2.0
4.38k stars 302 forks source link

Support entity classes that are inner classes #1006

Open mecoFarid opened 3 years ago

mecoFarid commented 3 years ago

Describe the bug Placing entity classes annotated with @Entity and @BaseEntity in another class will result in an error when building.

Basic info (please complete the following information):

To Reproduce Steps to reproduce the behavior: 1. Create the following hierarchy of classes and build

public class Holder {
    @BaseEntity
    public static abstract class Parent {
        @Id
        long boxId;
        private String text;

        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }
    }

    @Entity
    public static class Child extends Parent {
    }
}

Logs, stack traces Won't provide because this won't help in any way as IDE's build errors will be much clearer when dev-team build it themselves

greenrobot-team commented 3 years ago

Thanks for reporting! This is due to generated code missing imports of the inner class (error: cannot find symbol).

A workaround is to make at least the @Entity class a top-level class.

(An internal issue exists.)