ORMLite on Android using javax.persistence annotations

Viewed 2296

We have developed a web service and now are building an Android application to communicate with the web service. We use persistence in our web service and would also like to use persistence in our Android app. We figured that ORMLite was the way to go for persistency on Android and we are hoping that the javax.persistence support would be good enough for our app. I was hoping that I would be able to copy the web service's data model to the Android app and not having to modify the annotations.

So I tried copying the model classes and adding ormlite-android-4.41.jar and ormlite-core-4.41.jar to my Android project. Unfortunately this did not do the trick. My IDE can't find the classpaths for the javax.persistence annotations. Do I need additional libraries? I can't anything on that in the documentation.

2 Answers

If you are using maven. You can add this to your pom.xml:

<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
</dependency>

Alternatively you can download the jar file straight from the maven repository here then add it to the classpath. By the way, the @Table(name = "table_name") is not supported. You should substitute it with @Entity(name="table_name").

Related