Is it ok to take it from Glassfish project ( glassfish-persistence-api) or may be there is a Hibernate jar?
Hibernate is an implementation of the Java Persistence API, and where possible, you should use the standard annotations (in javax. persistence). This way, you could theoretically run your code on other JPA implementations. Only when you need Hibernate-specific functionality should you use the Hibernate annotations.
Package javax. persistence. A class that implements this interface can be used to convert entity attribute state into database column representation and back again.
If your javax. persistence. * import cannot be resolved, you will need to provide the jar that implements JPA. You can do that either by manually downloading it (and adding it to your project) or by adding a declaration to a dependency management tool (for eg, Ivy/Maven/Gradle).
persistence. Java Persistence is the API for the management for persistence and object/relational mapping. Used with the Access annotation to specify an access type to be applied to an entity class, mapped superclass, or embeddable class, or to a specific attribute of such a class.
If you are using maven, adding below dependency should work
<dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency>
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