You shouldn't `codeModel.ref(<a class>)` because it messed up sometimes.
Have a look to [EBeansHolder](https://github.com/excilys/androidannotations/tree/develop/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/EBeansHolder.java#L58) class instead.