1

Has anyone tried using both AutoValue and ActiveAndroid (or Ollie) on the same class?

Right now I am trying to use a library called ActiveAndroid to save data to the sqlite database. The library is structured by adding annotation, @Column, for each member variable. The problem is using ActiveAndroid and AutoValue on the same class. With AutoValue, I'm not suppose to add member variables since the apt will created them for me. This poses a problem for me because I won't be able to add @Column annotation to the member variable since it doesn't exist yet. So I was wondering anyone ran into this problem and if there is a workaround for it.

  • 1
    Hi and welcome to stackoverflow! This question is rather unclear -- what exactly are you trying to do and what is the problem with that? – Chris Beck Dec 22 '15 at 18:30

1 Answers1

0

This wouldn't work with AutoValue for the exact reason you point out. ActiveAndroid could update their library to work with standard property setter/getters, but currently the @Column annotation can only be applied to fields, not methods.

There is also the issue of your model objects having to subclass their abstract Model class. This shouldn't cause a problem, but does muddy the implementation quite a bit.

You might want to check out SQLDelight from the nice people as Square. As opposed to the ActiveAndroid style create-sqlite-from-java-objects approach, it takes the reverse create-java-objects-from-sql. It's up to you whether that's a benefit or a drawback, but it works quite nicely and plays well with AutoValue.

rharter
  • 2,495
  • 18
  • 34