239:
any annotations were added, and would return to POJO status if the annotations are removed then it can still be considered a POJO. Then the basic object remains a POJO in that it has no special characteristics (such as an implemented interface) that makes it a "Specialized Java Object" (SJO or (sic) SoJO).
238:
However, due to technical difficulties and other reasons, many software products or frameworks described as POJO-compliant actually still require the use of prespecified annotations for features such as persistence to work properly. The idea is that if the object (actually class) were a POJO before
672:
With the annotation as given above the bean isn't a truly pure POJO anymore, but since annotations are merely passive metadata this has far fewer harmful drawbacks compared to the invasiveness of having to extend classes and/or implement interfaces. Accordingly, the programming model is still very
479:
As designs using POJOs have become more commonly used, systems have arisen that give POJOs the full functionality used in frameworks and more choice about which areas of functionality are actually needed. In this model, the programmer creates nothing more than a POJO. This POJO purely focuses on
268:
that follow a simple naming convention. Because of this convention, simple declarative references can be made to the properties of arbitrary JavaBeans. Code using such a declarative reference does not have to know anything about the type of the bean, and the bean can be used with many frameworks
50:
The term "POJO" initially denoted a Java object which does not follow any of the major Java object models, conventions, or frameworks. It has since gained adoption as a language-agnostic term, because of the need for a common and easily understood term that contrasts with complicated object
619:
Thus, as an alternative to XML, many frameworks (e.g. Spring, EJB and JPA) allow annotations to be used instead of or in addition to XML. The following shows the same EJB bean as shown above but with an annotation added. In this case the XML file is no longer needed:
424:
library allows to change the code dynamically to integrate those conventions without the hassle to write them. The following code would generate the same bean, with the addition of an empty constructor :
46:"We wondered why people were so against using regular objects in their systems and concluded that it was because simple objects lacked a fancy name. So we gave them one, and it's caught on very nicely."
908:
Wahli, Ueli; Vieira, Miguel; Gomes, Ferreira Lopes; Hainey, Brian; Moharram, Ahmed; Napoli, JuanPablo; Rohr, Marco; Cui, Henry; Gan, Patrick; Gonzalez, Celso; Ugurlu, Pinar; Ziosi, Lara (29 June 2009).
572:
As given, the bean does not need to extend any EJB class or implement any EJB interface and also does not need to contain any EJB annotations. Instead, the programmer declares in an external
413:
Because of the JavaBean naming conventions the single "someProperty" reference can be automatically translated to the "getSomeProperty()" (or "isSomeProperty()" if the property is of
269:
without these frameworks having to know the exact type of the bean. The JavaBeans specification, if fully implemented, slightly breaks the POJO model as the class must implement the
616:
In practice, some people find annotations elegant, while they see XML as verbose, ugly and hard to maintain, yet others find annotations pollute the POJO model.
752:
114:
Ideally speaking, a POJO is a Java object not bound by any restriction other than those forced by the Java
Language Specification; i.e. a POJO
892:
940:
836:
467:
Other libraries or framework generate code (or bytecode) with those conventions directly. The addition of those tools help alleviate the
806:
918:
39:
261:
485:
285:
99:
73:
32:
488:(AOP) frameworks then transparently add cross-cutting concerns like persistence, transactions, security, and so on.
35:
273:
interface to be a true JavaBean. Many POJO classes still called JavaBeans do not meet this requirement. Since
945:
494:
was an early implementation of this idea and one of the driving forces behind popularizing this model.
760:
699:
507:
501:
84:
20:
705:
523:
The following shows a fully functional EJB bean, demonstrating how EJB3 leverages the POJO model:
417:) method for getting a value, and to the "setSomeProperty(String)" method for setting a value.
914:
888:
844:
814:
687:
511:
491:
468:
281:
209:
781:
710:
481:
265:
88:
934:
274:
270:
257:
414:
690:
and acceptable at points where more complex Java interfaces are not permitted.
733:
67:
103:
253:
59:
517:
55:
277:
is a marker (method-less) interface, this is not much of a burden.
471:, which in turn reduces the bugs frequency and maintenance cost .
518:
CDI (Contexts and
Dependency Injection for the Java EE platform)
79:
38:, not bound by any special restriction. The term was coined by
573:
94:
421:
837:"Controller with bare-bone Plain Old PHP Object aka POPO"
42:, Rebecca Parsons and Josh MacKenzie in September 2000:
911:
895:(www.manning.com/books/ejb-3-in-action). Chapter 11,
686:
A Plain old Java
Interface (POJI) is a basic form of
576:
file which EJB services should be added to the bean:
484:
and has no dependencies on (enterprise) frameworks.
62:for constructs that do not use fancy new features:
887:, Manning Publications Co., Shelter Island (NY),
883:Panda, Debu; Rahman, Reza; Lane, Derek; (2007).
307:The definition of the POJO can be as follows:
8:
863:
861:
753:"Return of the POJO: Plain 'Ole JavaScript"
16:Type of object in Java programming language
497:An example of an EJB bean being a POJO:
264:, and allows access to properties using
168:Implement prespecified interfaces, as in
728:
726:
722:
897:Deployment descriptors vs. annotations
7:
280:The following shows an example of a
78:"Plain old Documentation" (pod) in
299:"#{MyBean.someProperty}"
122:Extend prespecified classes, as in
72:"Plain old Ruby object" (PORO) in
14:
93:"Plain old PHP object" (POPO) in
66:"Plain old JavaScript object" in
673:much like the pure POJO model.
288:binding to a POJO's property:
1:
596:com.example.HelloWorldService
475:Transparently adding services
805:Kneschke, Jan (2007-02-19).
941:Java (programming language)
751:Almaer, Dion (2006-07-17).
486:Aspect-oriented programming
100:Plain old telephone service
962:
867:Martin, Robert C; (2008);
835:Cheong, Jym (2011-06-26).
807:"typesafe objects in PHP"
658:"Hello, world!"
611:</enterprise-beans>
558:"Hello, world!"
284:(JSF) component having a
266:getter and setter methods
216:@javax.persistence.Entity
873:Pure Java AOP Frameworks
682:Plain old Java Interface
622:
581:<enterprise-beans>
578:
525:
426:
309:
290:
213:
169:
123:
54:The term continues an
48:
605:</session-type>
243:Contextual variations
208:Contain prespecified
44:
25:plain old Java object
700:Data transfer object
601:<session-type>
508:Java Persistence API
502:Enterprise JavaBeans
260:, has a no-argument
85:Plain old CLR object
21:software engineering
706:Anemic domain model
598:</ejb-class>
429:@NoArgsConstructor
256:is a POJO that is
893:978-1-93-398834-4
634:HelloWorldService
594:<ejb-class>
591:</ejb-name>
534:HelloWorldService
510:(JPA) (including
31:) is an ordinary
953:
925:
924:
913:. IBM Redbooks.
905:
899:
881:
875:
865:
856:
855:
853:
852:
843:. Archived from
832:
826:
825:
823:
822:
813:. Archived from
802:
796:
795:
793:
792:
778:
772:
771:
769:
768:
759:. Archived from
748:
742:
741:
738:MartinFowler.com
734:"MF Bliki: POJO"
730:
677:Related Acronyms
668:
665:
662:
659:
656:
653:
650:
647:
644:
641:
638:
635:
632:
629:
626:
612:
609:
608:</session>
606:
602:
599:
595:
592:
588:
587:<ejb-name>
585:
582:
568:
565:
562:
559:
556:
553:
550:
547:
544:
541:
538:
535:
532:
529:
463:
460:
457:
454:
451:
448:
445:
442:
439:
436:
433:
430:
409:
406:
403:
400:
397:
394:
391:
388:
385:
382:
379:
376:
373:
370:
367:
364:
361:
358:
355:
352:
349:
346:
343:
340:
337:
334:
331:
328:
325:
322:
319:
316:
313:
303:
300:
297:
294:
282:JavaServer Faces
232:
229:
226:
223:
220:
217:
203:
200:
197:
194:
191:
188:
185:
182:
179:
176:
173:
163:
160:
157:
154:
151:
148:
145:
142:
139:
136:
133:
130:
127:
58:pattern to coin
961:
960:
956:
955:
954:
952:
951:
950:
946:Computer jargon
931:
930:
929:
928:
921:
907:
906:
902:
885:EJB 3 in action
882:
878:
866:
859:
850:
848:
834:
833:
829:
820:
818:
804:
803:
799:
790:
788:
780:
779:
775:
766:
764:
750:
749:
745:
732:
731:
724:
719:
696:
684:
679:
670:
669:
666:
663:
660:
657:
654:
651:
648:
645:
642:
639:
636:
633:
630:
627:
624:
614:
613:
610:
607:
604:
600:
597:
593:
590:
586:
584:<session>
583:
580:
570:
569:
566:
563:
560:
557:
554:
551:
548:
545:
542:
539:
536:
533:
530:
527:
477:
465:
464:
461:
458:
455:
452:
449:
446:
443:
440:
437:
434:
431:
428:
411:
410:
407:
404:
401:
398:
395:
392:
389:
386:
383:
380:
377:
374:
371:
369:setSomeProperty
368:
365:
362:
359:
356:
353:
350:
347:
344:
342:getSomeProperty
341:
338:
335:
332:
329:
326:
323:
320:
317:
314:
311:
305:
304:
301:
298:
295:
293:<h:inputText
292:
250:
245:
234:
233:
230:
227:
224:
221:
218:
215:
205:
204:
201:
198:
195:
192:
189:
186:
183:
180:
177:
174:
171:
165:
164:
161:
158:
155:
152:
149:
146:
143:
140:
137:
134:
131:
128:
125:
112:
17:
12:
11:
5:
959:
957:
949:
948:
943:
933:
932:
927:
926:
920:978-0738432892
919:
900:
876:
871:, Chapter 11,
857:
827:
797:
782:"POCO Support"
773:
743:
721:
720:
718:
715:
714:
713:
711:KISS principle
708:
703:
695:
692:
688:Java interface
683:
680:
678:
675:
623:
579:
526:
521:
520:
515:
505:
482:business logic
476:
473:
427:
310:
291:
249:
246:
244:
241:
236:
235:
214:
206:
170:
166:
124:
111:
108:
107:
106:
97:
91:
89:.NET Framework
87:(POCO) in the
82:
76:
70:
15:
13:
10:
9:
6:
4:
3:
2:
958:
947:
944:
942:
939:
938:
936:
922:
916:
912:
904:
901:
898:
894:
890:
886:
880:
877:
874:
870:
864:
862:
858:
847:on 2012-03-26
846:
842:
838:
831:
828:
817:on 2012-03-26
816:
812:
808:
801:
798:
787:
786:microsoft.com
783:
777:
774:
763:on 2014-09-13
762:
758:
754:
747:
744:
739:
735:
729:
727:
723:
716:
712:
709:
707:
704:
701:
698:
697:
693:
691:
689:
681:
676:
674:
621:
617:
577:
575:
524:
519:
516:
513:
509:
506:
503:
500:
499:
498:
495:
493:
489:
487:
483:
474:
472:
470:
425:
423:
418:
416:
308:
289:
287:
286:bidirectional
283:
278:
276:
272:
267:
263:
259:
255:
247:
242:
240:
211:
207:
167:
121:
120:
119:
117:
109:
105:
101:
98:
96:
92:
90:
86:
83:
81:
77:
75:
71:
69:
65:
64:
63:
61:
57:
52:
47:
43:
41:
40:Martin Fowler
37:
34:
30:
26:
22:
910:
903:
896:
884:
879:
872:
868:
849:. Retrieved
845:the original
840:
830:
819:. Retrieved
815:the original
810:
800:
789:. Retrieved
785:
776:
765:. Retrieved
761:the original
756:
746:
737:
685:
671:
618:
615:
571:
522:
496:
490:
478:
466:
456:someProperty
419:
415:Boolean type
412:
399:someProperty
393:someProperty
378:someProperty
354:someProperty
330:someProperty
306:
279:
275:Serializable
271:Serializable
258:serializable
251:
237:
115:
113:
53:
51:frameworks.
49:
45:
28:
24:
18:
811:kneschke.de
469:boilerplate
262:constructor
210:annotations
156:HttpServlet
935:Categories
869:Clean Code
851:2012-05-27
821:2012-05-27
791:2012-05-27
767:2014-08-19
717:References
625:@Stateless
589:helloWorld
196:EntityBean
181:implements
116:should not
110:Definition
102:(POTS) in
68:JavaScript
603:stateless
512:Hibernate
248:JavaBeans
104:telephony
60:retronyms
694:See also
646:sayHello
546:sayHello
254:JavaBean
118:have to
757:Ajaxian
450:private
447:@Setter
444:@Getter
324:private
212:, as in
144:servlet
135:extends
56:acronym
917:
891:
841:jym.sg
655:return
643:String
640:public
628:public
555:return
543:String
540:public
528:public
504:(EJB),
492:Spring
453:String
438:MyBean
432:public
422:lombok
375:String
363:public
351:return
339:String
336:public
327:String
318:MyBean
312:public
296:value=
219:public
172:public
126:public
36:object
702:(DTO)
631:class
531:class
435:class
315:class
302:/>
222:class
184:javax
175:class
138:javax
129:class
915:ISBN
889:ISBN
420:The
387:this
366:void
150:http
80:Perl
74:Ruby
33:Java
29:POJO
23:, a
574:XML
231:...
225:Baz
202:...
190:ejb
178:Bar
162:...
132:Foo
95:PHP
19:In
937::
860:^
839:.
809:.
784:.
755:.
736:.
725:^
649:()
549:()
345:()
252:A
923:.
854:.
824:.
794:.
770:.
740:.
667:}
664:}
661:;
652:{
637:{
567:}
564:}
561:;
552:{
537:{
514:)
462:}
459:;
441:{
408:}
405:}
402:;
396:=
390:.
384:{
381:)
372:(
360:}
357:;
348:{
333:;
321:{
228:{
199:{
193:.
187:.
159:{
153:.
147:.
141:.
27:(
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.