ORMLite on Android with javax.persistence annotations

We have developed a web service and are now creating an Android application to communicate with the web service. We use persistence in our web service, and also would like to use perseverance in our Android application. We concluded that ORMLite is a way to promote on Android, and we hope that the javax.persistence support will be good enough for our application. I was hoping that I could copy the web services data model into the Android application and not change the annotations.

So, I tried to copy the model classes and add ormlite-android-4.41.jar and ormlite-core-4.41.jar to my Android project. Unfortunately, this did not help. My IDE cannot find class paths for javax.persistence annotations. Are additional libraries needed? There is nothing I can do about the documentation.

+7
source share
2 answers

Interest Ask. If javax.persistence annotations javax.persistence not in the Android JDK, I'm not sure if you should use them.

However, if you want to use them, you can get java files from the JDK source and include them in your own project. Just copy the annotations that you are actually using from the source jar into the appropriate javax/persistence path.

ORMLite support for javax.persistence annotations is far from perfect. If you have any problems, let me know so that I can improve them.

+4
source

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 directly from the maven repository here , then add it to the classpath. By the way, @Table(name = "table_name") not supported. You should replace it with @Entity(name="table_name") .

+5
source

All Articles