Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference Between java bean And POJO  RSS feed

 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please let me know the difference between Java bean and POJO..
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A POJO is a "Plain Old Java Object" and doesn't specify anything except that it isn't tied to a framework or have fancy code like JEE bits and pieces.
A Java Bean is a specification which requires a Java Class to be serializable, have a no-arg constructor and a getter and setter for each field (and each getter/setter must be in a particular form)

Therefore a bean is a POJO but a POJO may not be a bean, except that some tools refer to classes as beans when strictly they are not (such as in Spring) but this usually for the better since it makes the classes easier to use.
 
Vinod Vinu
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Bean and POJO are more or less same. POJO are Plain Old Java Objects, also known as entity class. Java Beans are again the same only. All please correct me if wrong in somewhere
 
Mohamed Sanaulla
Bartender
Posts: 3174
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David O'Meara wrote:
Therefore a bean is a POJO but a POJO may not be a bean, ...


+1 This is what I thought of first when I saw this post.

[Dave - fixed a typo and hid the evidence]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!