How to use JPA annotations in ormlite?

I would like to use JPA annotations in ormlite. These annotations (e.g. @Entity or @Id) apply to the javax.persistence package, which is apparently not provided with ormlite. I could not allow JPA annotations, while individual annotations to create (e.g. @DatabaseTable) were approved. Do I need to download a third-party jar to get JPA annotations that work in ormlite?

I need to work only with ormlite + JPA.

When you look at http://ormlite.com/javadoc/ormlite-core/index-all.html , we can see that the JPA annotations are not documented and are not available, although they are described in the user manual.

Thank you very much in advance !!!

+4
source share
2 answers

javax.persistence is available in the bank from the maven central repository (for example). It contains all annotations, as well as all other JPA stuff that ORMLite ignores.

+4
source

Instead of using ORMLite annotations, you can use the more standard JPA annotations from the javax.persistence package. Instead of the @DatabaseTable annotation @DatabaseTable you can use the javax.persistence @Entity annotation. For instance:

 @Entity(name = "accounts") public class Account { … 

Check full documentation here

-1
source

Source: https://habr.com/ru/post/1438640/


All Articles