We have a project that uses JPA/Hibernate on the server side, the mapped entity classes are in their own Library-Project and use Annotations to be mapped to the database. I want to use these classes in an Android-Project - is there any way to ignore the annotations within Android, to use these classes as standard POJOs?
Annotations allow you to provide hints to code inspections tools like Lint, to help detect these more subtle code problems. They are added as metadata tags that you attach to variables, parameters, and return values to inspect method return values, passed parameters, local variables, and fields.
The JPA annotation @Embedded is used to embed a type into another entity.
You can use Cmobilecom JPA for android and java. It implements JPA 2.1 specification. So all your JPA annotations for java will work for android without any changes. Simply add the following dependencies in your projects.
Android:
dependencies {
implementation("com.cmobilecom:cmobilecom-jpa-android:${version}@aar") {
transitive = true
}
annotationProcessor "com.cmobilecom:cmobilecom-jpa-processor:$version"
}
JDBC:
dependencies {
implementation "com.cmobilecom:cmobilecom-jpa-jdbc:$version"
// annotation processor: generate static metamodel
compileOnly "com.cmobilecom:cmobilecom-jpa-processor:$version"
}
Disclaimer: I am a developer of Cmobilecom JPA.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With