Massively Scalable Applications

JEE Annotations

This tutorial consolidates a list of frequently used annotations for important JEE frameworks - Spring, Hibernate, JPA, JAXB, Web Services, and jUnit. It contains usage instructions, code examples and important tips (nitty-gritty details that every developer using these annotations should know). In this tutorial, you will also learn:

  1. How to use JAXB and Hibernate-JPA annotations in conjunction to convert your data in entity beans to XML or JSON format
  2. How to use JAX-RS with JAXB and JPA annotations to exchange data with rich clients using REST based web services
  3. How to use Spring and jUnit annotations in conjunction to test spring based applications
This is an advanced tutorial. Please see Prerequisite section below. There are many documents on the Internet that describe annotations for different frameworks in detail and some of them are mentioned in the 'References' section below. The focus of this tutorial is on frequently used annotations in multiple JEE frameworks, important tips on them and how to use them in conjunction.

This tutorial is structured into 5 parts as shown in 'Contents' table below.


This tutorial assumes that the reader knows commonly used JEE technologies like Spring, Hibernate, JPA, REST, JAXB, jUnit. A basic knowledge about annotations is also required. This is NOT a step by step tutorial where you learn how to build Spring, Hibernate based applications, rather it helps you learn about frequently used annotations in multiple JEE technologies (Please see Technology Stack used in our tutorial.) You will also learn how to use annotations from different technologies in conjunction and their benefits.

Example Application

The example application we will refer in this tutorial has the following functionality:
  • Create a new company
  • Create contacts in that company
  • Display list of companies and view company detail for any company
  • Display list of contacts that belong to the selected company

Technology Stack

The focus of this tutorial is Annotations used in different JEE frameworks required for developing enterprise applications. The technologies we are using for our example application are:
  • Spring as IOC/DI framework, bean management, Spring MVC
  • Spring security for authentication and authorization
  • Hibernate -JPA as persistence framework
  • Jersey for RESTful Web Services. We will use JAX-RS annotations.
  • JAXB annotations to convert our data objects into desired JSON, XML format to be consumed by rich clients like jQuery or Ext-js
  • jUnit for unit testing our spring based application

Database Model

The database we have designed is to explain various association mappings and related annotations. The ERD for our example application database can be viewed here.


  1. Spring Annotations:
  2. Spring Framework Reference:
  3. Hibernate Annotations:
  4. Inheritance Mapping Reference:
  5. Jersey JAX-RS Annotations:
  6. JAXB Annotations:
  7. Annotations for Unit Testing Spring applications: