Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Id Annotation isn't inherited by child classes #37

Closed
deusprogrammer opened this issue Nov 27, 2017 · 3 comments
Closed

Id Annotation isn't inherited by child classes #37

deusprogrammer opened this issue Nov 27, 2017 · 3 comments
Assignees
Milestone

Comments

@deusprogrammer
Copy link

Perhaps an annotation similar to @MappedSuper in JPA so if I am using the same id field in each entity I can just extend a parent class instead of having to mark up an id field in every class.

Otherwise great library, much better than CouchbaseLite. Especially since it doesn't require any native libraries.

@anidotnet anidotnet self-assigned this Nov 28, 2017
@anidotnet anidotnet added this to the 2.1.0 milestone Nov 28, 2017
@anidotnet
Copy link
Contributor

Thanks for the kind words, I am glad you like it.

For the feature itself, I am working on it.

anidotnet added a commit that referenced this issue Nov 28, 2017
@anidotnet
Copy link
Contributor

This feature should be available in 2.1.0.SNAPSHOT now.

I have added a new annotation @InheritIndices that you should apply on the child class. Once applied it will consider all index related annotations @Id, @Index, @Indices through out the class hierarchy.

The feature works like as follows:

@Index(value = "text", type = IndexType.Fulltext)
public class SuperDuperClass {
    public String text;
}

@Indices(
        @Index(value = "date", type = IndexType.Unique)
)
public class ParentClass extends SuperDuperClass {
    @Id
    public Long id;
    public Date date;
}

@InheritIndices
public class ChildClass extends ParentClass {
    public String name;
}

Now the ChildClass will have indices for fields - text, date and id.

anidotnet added a commit that referenced this issue Nov 28, 2017
@deusprogrammer
Copy link
Author

deusprogrammer commented Nov 28, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants