1

I want to create a mini ORM(Object Relational Mapping) for android if some one of you have used Hibernate which is also an ORM but not for mobile in which you can create Class to Table mapping by using annotations. What i want to create my annotations in android and than read that class by reflection and create tables.

in standard java i am able to create my annotations and use it. but for android i could not found any way to create annotations in android This project using custom annotations but i could not found how.

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)

These above Meta-Annotations are available in standard java but not in android which help to create annotations

any help please

Yahya Arshad
  • 1,626
  • 2
  • 19
  • 34

1 Answers1

2

What makes you think that these annotations are not available in Android? ORMLite is a Java ORM for Android that uses annotations without problem:

@Target(value = FIELD)
@Retention(value = RUNTIME)
public @interface DatabaseField {
    ...
}

I also use METHOD retention elsewhere. Here's the source code for @DatabaseField that compiles fine under all Android versions that I've tried (1.6 up through 3.0).

One thing to remember about annotations with Android is that their performance is terrible. See:

Why are annotations under Android such a performance issue (slow)?

Community
  • 1
  • 1
Gray
  • 115,027
  • 24
  • 293
  • 354
  • I was tried to use it but i think due to any reason it didn't work. and after reading your point that annotations cause performance issue. now thinking to leave it :( – Yahya Arshad Aug 02 '12 at 14:06
  • Make sure to check out ORMLite @Cheeta. It sounds like you were trying to do what it does. You can also configure classes with config files to bypass the annotation startup issues. http://ormlite.com/ – Gray Aug 02 '12 at 14:12