How can I use javax.persistence with ORMLite in Android?

647 views
Skip to first unread message

Manoel Campos da Silva Filho

unread,
Oct 23, 2012, 1:56:06 PM10/23/12
to ormlite...@googlegroups.com
Hello, I'm using ORMLite 4.42.

I would like to know about the support to JPA annotations at Android 2.3.
I searched at the forum but I didn't find aswers.
I see that the JPA support is not complete.
I imported the ormlite-core-4.42.jar and ormlite-android-4.42.jar
at my Android project but I can't use the javax.persistence annotations.
The javax.persistence package isn't available.

Manoel Campos da Silva Filho

unread,
Oct 31, 2012, 11:25:10 AM10/31/12
to ormlite...@googlegroups.com
Did someone already used JPA with ORMLite at Android?

Lauri Ampuja

unread,
Nov 6, 2012, 2:41:37 PM11/6/12
to ormlite...@googlegroups.com
I have same question... seems like not so many... in whole internet...

Gray Watson

unread,
Nov 6, 2012, 3:10:13 PM11/6/12
to ormlite...@googlegroups.com
On Oct 23, 2012, at 1:56 PM, Manoel Campos da Silva Filho wrote:

> I would like to know about the support to JPA annotations at Android 2.3.
> I searched at the forum but I didn't find aswers.
> I see that the JPA support is not complete.

Right.

> I imported the ormlite-core-4.42.jar and ormlite-android-4.42.jar
> at my Android project but I can't use the javax.persistence annotations.
> The javax.persistence package isn't available.

So ORMLite has limited support for the JPA annotations. I would be happy to improve the support with feedback from people.

That said, it does _not_ provide the javax.persistence classes. The JRE is supposed to do that. If Android does not have those classes then I guess you are going to have to provide them yourself. I don't have any plans of adding them to ORMLite if that is the question.

If that _isn't_ the question, then please add more details.

thanks,
gray

Manoel Campos da Silva Filho

unread,
Nov 6, 2012, 3:28:19 PM11/6/12
to ormlite...@googlegroups.com
Thank you Gray.
That is the question.
So, Android 2.3 doesn't provide JPA annotation classes.

HOUSSEM ZAIER

unread,
Nov 6, 2012, 3:46:20 PM11/6/12
to ormlite...@googlegroups.com
Hi there,
 I've worked on Android 2.1 and I couldn't integrate JPA annotation with ORMLite . I couln't get an error on compiling as I remember  but the IDE (ECLYPSE) blocks ! it took 700 MB RAM shown at  the memory manager of windows ! 
Does anyone has used it with any other Android version?
peace.


2012/11/6 Manoel Campos da Silva Filho <manoel...@gmail.com>



--
Zaier Houssem
Ingénieur développeur web/mobile   
           Skype: houssemzaier
            Tel:  98820145

Dave

unread,
Dec 19, 2012, 12:00:21 PM12/19/12
to ormlite...@googlegroups.com
Hi,

you can get an implementation of JSR-317 JPA 2.0 from (use maven/gradle/sbt for remaining dependencies)
http://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.0-api/1.0.1.Final (101 kB)
or
http://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-jpa_2.0_spec/1.1 (118 kB)
It doesn't matter which one you take. The apk file size is eventually the same

If you use proguard you need to keep the JPA annotations as well.
Add:
-keep class javax.persistence.* {
*;
}

to the configuration of proguard
Otherwise you get in runtime:

java.lang.IllegalArgumentException: No fields have a DatabaseField annotation


Apk file size is about 15kB bigger for my app with JPA.

Op dinsdag 23 oktober 2012 19:56:06 UTC+2 schreef Manoel Campos da Silva Filho het volgende:

Dave

unread,
Dec 19, 2012, 1:56:58 PM12/19/12
to ormlite...@googlegroups.com


Op woensdag 19 december 2012 18:00:21 UTC+1 schreef Dave het volgende:
Hi,

you can get an implementation of JSR-317 JPA 2.0 from (use maven/gradle/sbt for remaining dependencies)
http://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.0-api/1.0.1.Final (101 kB)
or
http://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-jpa_2.0_spec/1.1 (118 kB)
It doesn't matter which one you take. The apk file size is eventually the same



Maybe the Apache license is better but I am not a lawyer.

Geronimo JPA
Apache License Version 2.0, January 2004
http://www.apache.org/licenses/LICENSE-2.0.html

Hibernate JPA
Eclipse Distribution License - v 1.0
http://www.eclipse.org/org/documents/edl-v10.php
 
Reply all
Reply to author
Forward
0 new messages