aspose file tools
The moose likes Java in General and the fly likes what is POJO? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "what is POJO?" Watch "what is POJO?" New topic
Author

what is POJO?

Alex Kravets
Ranch Hand

Joined: Jan 24, 2001
Posts: 476
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


All right brain, you don't like me and I don't like you, but let's just do this one thing so I can get back to killing you with beer.<br /> <br />- Homer Simpson
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
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

Joined: Jan 24, 2001
Posts: 476
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 ]
Steve McCann
Ranch Hand

Joined: Oct 20, 2004
Posts: 81
I read 'POJO' to be the same as a JavaBean in that it is a simple class with getters/setters.

Steve
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
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).


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: what is POJO?
 
Similar Threads
BO vs POJO
advantages of EJB
Struts2 annotation validation
how many layers in jpetstore application ?
pojo and java bean