Wednesday, April 13, 2011

"Configuration by Exception" Mechanism

Java EE 5 introduced the idea of configuration by exception (sometimes referred to as programming by exception or convention over configuration). This means, unless specified differently, the container or provider should apply the default rules. In other words, having to supply a configuration is the exception to the rule. This allows you to write the minimum amount of code to get your application running, relying on the container and provider defaults.

This concept is commonly used in JPA(Java Persistence API) where the mapping rules are specified as annotations. If you do not specify these rules, the classes will behave as simple POJOs.

Consider the following example:


public class Student {


private Long id;

private String name;

private Float rollno;

public Student()



….. // setters and getters


If you do not provide @Entity and @Id annotations, still Student will behave like a POJO and not be persisted.


Mary Brown said...

The notion of configuration by exception means that the JPA persistence engine defines defaults.

Java Persistence API Training in Chennai

Victoria John said...

Java is one of the popular technologies with improved job opportunity for hopeful professionals. Java Training in Chennai helps you to study this technology in details.

Anonymous said...

@Victoria that an additional input to the previous explanations or an advertisement for your dream company?

Roshini Balu said...

You are doing a great job, sharing our knowledge is the way of developing our skills then only we can get a deep clean solution for that unresolved problems, I appreciate your effort keep sharing.
JAVA Course in Chennai

Roshini RS said...

I have read all the articles in your blog; was really impressed after reading it. FITA is glad
To inform you that; we provide practical training on all the technologies with MNC exports. We
Assure you that through our training the students will gain all the sufficient knowledge to have a voyage in IT industry.
Fita academy reviews

Roshini RS said...

Thanks for sharing this valuable information to our vision.

Fita Chennai Reviews, Fita Chennai Complaints, Fita Academy Reviews, Fita Reviews

dhanamlakshmi palu said...

Your posts is really helpful for me.Thanks for your wonderful post. I am very happy to read your post. CCNA Training in chennai | CCNA Training chennai | CCNA course in chennai | CCNA course chennai

pallavi said...

its really helped...thanks a lot