JaRB aims to improve database usage in Java enterprise applications.

Key features

Translate JDBC exceptions

JDBC runtime exceptions will automatically be translated into a usefull exception, giving us access to all desired constraint information. For example, whenever a unique key constraint is violated, we will translate the SQLException into a UniqueKeyAlreadyExistsException, offering us all relevant information.

It is even possible to map custom exceptions on named constraints, allowing us to write domain specific and, most importantly, understandable code.

public class PostTitleAlreadyExistsException
  extends UniqueKeyViolationException {

JSR303 validation on schema

To validate database constraints with JSR303, we often need to duplicate constraint information in both the database and entity class. Duplication is never good, so we made a @DatabaseConstrained annotation that dynamically validates all simple database constraints based on JDBC metadata.

@DatabaseConstrained @Entity
public class Person {
 @Id @GeneratedValue
 private Long id;
 private String name;

Database migration

Data insertion


JaRB is simple to integrate in your Spring project, just add the following to your context:

@EnableDatabaseConstraints(basePackage = "com.myproject")

Maven dependencies


You can also download the artifact(s) on Maven Search


Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.