• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is POJO?  RSS feed

 
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen a lot of reference to POJO (Plain Old Java Object, we love acronyms, don't we ). But what is it exectly? Is any class a POJO? Can someone please explain?

thanks,
Alex
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is any class a POJO?


Pretty much. It is normally used with reference to a persistence technology such as Hibernate. Here the "POJO" differenciates from the non-POJO alternative: an Entity Bean. Basically an Entity Bean relies on the environment it is deployed in to work, so gets behaviour and properties from the container it is deployed in. This isn't true of a POJO, which contains all its own properties and provided methods to define its own behaviour.
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pretty much any class is a POJO, but it depends a bit on the context of the conversation.

For example if you are talking about persistence, saying that the persistence layer will work with POJO's means that you're not forced to subclass something from that framework in order to use the framework. You may have to follow some general coding practices (such as basic Java Bean standard getters/setters and maybe a no args constructor), but no requirments in terms of special subclassing or interface implementation.

The framework in question will usually use some or all of reflection, config files, bytecode manipulation, dynamic code generation/subclassing, and there are probably other techniques I've left off.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see, a POJO is better related to JavaBean where it's a self contained class, a component perhaps (server side)?
[ June 29, 2005: Message edited by: Alex Kravets ]
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read 'POJO' to be the same as a JavaBean in that it is a simple class with getters/setters.

Steve
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many developers will write POJOs for business logic, to be invoked by servlets, EJBs, Struts Actions, etc. In such a case, the POJO must be declared public and must not be tied to any client (in the interest of reusability).
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!