Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java bean validation 2.0 vs hibernate validator

what is difference b/w java bean validation 2.0 and hibernate validator. is both are same or different. because both look like same. can you discuss differences between java bean validation 2.0 and hibernate validator.

which one should I use in my project?

Thanks

like image 439
Arayan Singh Avatar asked Jan 02 '23 14:01

Arayan Singh


1 Answers

Bean Validation 2.0 is a Java specification called JSR-380 which defines the API.

The Bean Validation api jar, e.g. validation-api-2.0.1.jar, contains only interfaces / annotations etc, no implementations.

Hibernate Validator (6.0.1+) is the reference implementation, and currently the only certified implementation of JSR-380.

Java specifications (JSRs) are developed under the Java Community Process (JCP). In addition to delivering a formalised specification for an API, the JSR would often include a reference implementation but other vendors are free to provide their own implementation.

Compare this with the Java Persistence API (JPA) specification JSR-317. There are several different vendors with competing JPA implementations, including Hibernate, EclipseLink (the reference implementation for JSR-317), OpenJPA etc.

In the case of Bean Validation 2.0, there just are no competing implementations at present, just the reference implementation.

like image 189
codemonkey Avatar answered Jan 08 '23 05:01

codemonkey