Originally published in DeveloperIQ magazine
The J2EE field is agog with excitement about a very popular open-source technology , Hibernate , being elevated to the status of JCP standard. Feedback from J2EE programmers in industry says that knowledge of Hibernate is mandatory for all J2EE aspirants. In this short tutorial , the author attempts to trace the reasons for this new trend & to alert us , to the imminent and dramatic changes in the J2EE landscape.
What is Hibernate?
HIBERNATE is an ORM ( Object-Relational-Mapping) technology. It is an Open-Source and free technology , developed in SourceForge.net. There have been a number of such ORM technologies,in recent past.. TopLink is one such tool , subsequently adopted by Oracle and so proprietory.
Hibernate from SourceForge and OJB(Object-Relational-Bridge) from Apache are two well known ORM tools,open-source and free. JDO , also falls within the same category.
Gavin King is the lead for Hibernate and Craig Russell & David Jordan , the lead authors for SUN-sponsored JDO effort. Due to some technical problems, it appears that the majority in JCP favors Hibernate today instead of JDO.At first reading though, the difference is not, all that apparent. The syntax and the approach appear to be almost same,but Hibernate syntax is easier to learn.
It is interesting to note that Craig Russell works for SUN and Gavin King is now with JBoss. It shows that JCP is a democratic community and SUN is not dictating terms except to protect the language and its enterprise-level users.
Hibernate and EJB 3.0
EJB-3 , is the latest version and it is heavily influenced by Hibernate. Some readers equate EJB-3 with Hibernate. Some even equate EJB-3 with JBOSS! Oracle supports EJB-3 proposals and as it is the main Database company in j2ee world, EJB-3 has bright future. J2EE( Java Enterprise Edition) by its very name is an Enterprise level technology, and as EJB is the essence of such Enterprise applications, because of the built-in container services offered, the significance of the surging interest in Hibernate can be really appreciated only in association with EJB and hence a detour into EJB is inevitable.
EJB has three types. One type is the SESSION BEAN,residing in ENTERPRISE container, which can be thought of as a function-bean, invoked in RMI-IIOP style. (this is a rough definition).Such session-bean , may be either stateless or stateful.
This type of EJB has stood the test of time during the last six years and has even gained wide approval, even for data-access, especially since it fits very well with the emerging XML WebService technology, and is very easy to learn and implement.( The earlier tutorial on EJB as webservice in Feb-2005, in DeveloperIQ illustrates this feature).The stateless bean working in Enterprise container has an exact counter-part in Microsoft COM+(MTS), but the other types are said to be available in MS platform only through third-party extensions.
ORM tools have been sometimes used along with Session beans. The only problem till recently was that they were proprietary and rather costly. But nowadays, very reliable open-source ORM tools are available, and even Richard Monson Haefel ( an acknowledged authority and author on EJB)approves this method as a safe and productive alternative to Entity beans.( page-467..EJB by Haefel-OReilly).
The other branch, the ENTITY BEAN has been less lucky. EJB-1.1, EJB-2.0 and then EJB-2.1 , have meant a number of changes in the specification relating to Entity Beans. We can say that an Entity bean is an ‘Attribute bean’ or ‘property-bean’, with setter and getter methods, invoked in RMI-IIOP style and persisted in Enterprise container. The pattern of defining a typical Javabean is a recurring theme in Java. The same style occurs in BDK,EJB-Entity beans, Struts,JSF and now in Hibernate too. So, it is very important and elegant.
The third branch is Messaging paradigm and MDB. A recent article in the web dubbed the ‘RPC’ style, on which the previous two types of EJB are based, as stone-age technologies! An Enterprise by its very name implies huge number of customers and concurrent transactions, RPC style being like telephone call, could result in ‘line-engaged!’ problem. If the call involves the called person referring to some records before replying, it leads to line- blocking. But, messaging style, as in email, at least ensures that the message has been sent. It is evident that dubbing RPC( read ‘telephone’) as unsuitable , is over-statement. Sometimes, we desire immediate response, too. By the same token, even XML webservice , if it is really serious, should adopt messaging style and it does.MDB (Message-Driven bean) has weathered the storm and is in fact gaining more and more acceptance.
Latest posts by Krishna Srinivasan (see all)
- 5 New Features in HTML5 - November 29, 2013
- How To Set Tomcat JVM Heap Size in Eclipse? - November 28, 2013
- How To Resolve “Resource Is Out Of Sync With The Filesystem” Error in Eclipse? - November 28, 2013
Pages: 1 2