Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What jar should I include to use javax.persistence package in a hibernate based application?

Is it ok to take it from Glassfish project ( glassfish-persistence-api) or may be there is a Hibernate jar?

like image 403
Sergey Avatar asked Apr 10 '09 12:04

Sergey


People also ask

Is javax persistence part of hibernate?

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.

Which package is required persistence annotations in Java?

Package javax. persistence. A class that implements this interface can be used to convert entity attribute state into database column representation and back again.

Can not import javax persistence?

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).

What is javax persistence used for?

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.


1 Answers

If you are using maven, adding below dependency should work

<dependency>     <groupId>javax.persistence</groupId>     <artifactId>persistence-api</artifactId>     <version>1.0</version> </dependency> 
like image 133
Bahadır Yağan Avatar answered Sep 21 '22 14:09

Bahadır Yağan