Optimizing Software Development
RSS icon Email icon Home icon
  • Hibernate: Return on Investment (ROI)

    Posted on September 19th, 2006 levent.gurses 1 comment

    For technology experts and developers alike, the term Return on Investment (ROI) is a bit of a blurry subject. Yet, it is one of the most common themes during product evaluation and technology platform selection. It is mostly the management that seems to be interested in the projected ROI
    for a specific product or service.

    In the old days when corporations used to pay for software, the evaluation of a specific product with regards to its cost/benefit ratio and especially the cost to the enterprise was relatively easier. With the advancement of the open-source movement and the proliferation of free, proven, open-standard frameworks the traditional ROI analysis needed an update. More than the initial cost of an open-source product - common item in paid software, the overall cost or the Total Cost of Ownership (TCO) of the product needed to be placed under the spotlight.

    Let me make one thing clear. For an enterprise psychologically unprepared to embrace open-source, there is very little any ROI analysis can do. Enterprises should begin with accepting the idea that open-source works, is “really-really” free, is here to stay, and that to get ahead they have to invest in it. After this acknowledgment, ROI analysis can be though as a just another standard procedure or cost projection tool.

    In this paper, I will analyze the ROI analysis for open source projects and support my case with empirical numbers taken from a fairly large enterprise adopting Hibernate, an open-source Object/Relational (O/R) mapping tool. I’ll try to articulate a clear picture on the projected Return on Investment (ROI) both for the immediate and long-term gains.

    I’ll present each item with its order of importance to the overall ROI. At
    the end of the paper there will be a section with the risks associated to this adoption and some empirical numbers portraying a dollar amount estimate in a small pilot project.

    Hibernate (www.hibernate.org)

    Hibernate is a widely accepted, open-source Object/Relational mapping framework for the Java and J2EE environments. The Hibernate group has been recently acquired by Jboss, adding to the growing momentum of the technology.

    Benefits

    Price of Acquisition and licensing

    Hibernate is distributed freely, under the LPGP license. The LGPL license is sufficiently flexible to allow the use of Hibernate in both open source and commercial projects.

    Industry Momentum

    Hibernate
    is a widely used O/R Java solution. The momentum surrounding its stable technology is not just perceived, as there are two key events indicating as such:

    • Gavin
      King (creator of Hibernate) was chosen to lead the Sun EJB Expert Group for EJB 3.0. This was due to proven techniques and advantages of the Hibernate solution. Undoubtedly, EJB 3.0 will favor Hibernate design and solutions.
    • JBoss, arguably the most leveraged open-source J2EE application server, has emerged with Hibernate and now develops its technology.

    EJB 3.0

    The Sun EJB Expert Group for EJB 3.0 is dramatically changing the persistence aspects of EJB, both from a design and API perspective. This potentially could open up EJB usage to a larger set of business cases. Having a Hibernate knowledge base will ease the transition to future EJB technologies.

    Isolated Initial Usage - Pilot Project

    Using Hibernate on a pilot project will allow the enterprise and its architects to establish a standard set of practices with the technology. This could then be rolled out for the next release and beyond.

    Ease of Use and Flexibility

    Due to Hibernate’s declarative nature, it is quite easy to program to, as well as integrate with an existing J2EE application. Hibernate resides on the south side of any multi-layer application, close to the physical data layer. As such, it seamlessly blends into your application with minimal intrusion on your existing design patterns. As an example, one can continue to use DAOs or Entity EJBs with Hibernate in the same way you would use them without it. As risk mitigation strategy, Hibernate can be swapped out with minimal touch points on the design.

    Hibernate adapts to the development process, no matter if a team starts with a design from scratch or works with a legacy database. Hibernate generates SQL, relieving developers from manual result set handling and object conversion. Hibernate also provides transparent persistence that
    allows systems to use any database and to switch between databases.

    Reduction in Application Code

    The persistence of any domain component can be prototyped to gain insight on developer burden for the Hibernate technology. A particular DAO Java class for persisting a key domain object (i.e., User) can be reduced by over 50%.

    Developer Productivity

    Hibernate features a natural programming model that supports natural Object-Oriented idioms - inheritance, polymorphism, composition and the
    Java collections framework. It can also run outside of an application server allowing you to expedite the code/test cycle and skip the deployment step.

    Performance

    Hibernate supports various caching managers. It is a fast performer, has a dual-layer cache architecture, and may be used in a cluster. It’s pure Java design also allows it to be used in any J2EE application server

    Other Technical Advantages

    • Support for Ultra-Fine-Grained Object Models - a rich variety of mappings for collections and dependent objects.
    • No Build-Time Byte code Enhancement - there’s no extra code generation or byte code processing steps in your build procedure.
    • Logical Query Language - Hibernate addresses both sides of the problem: not only how to get objects into the database but also how to get them out again.
    • Transparent Persistence - no required interfaces or base classes for persistent classes. JavaBean style properties are persisted. No build-time source or byte code generation or processing for faster build procedures. Also includes support for extensive subset of Java APIs.
    • Object-Oriented Query Language - powerful query language expressed in a familiar SQL-like language. Includes full support for polymorphic queries. Queries may also be expressed in the native SQL dialect of your database.
    • Flexible Object/Relational Mapping -includes threedifferent O/R mapping strategies including 1) table-per-class hierarchy,  2) table-per-subclass (normalized mapping), and 3) table-per-concrete-class. Multiple objects to single row mapping allow for use of fine-grained object composition. Polymorphic associations including many-to-one, one-to-many, many-to-many,
      one-to-one, and ternary maps are also possible for all mapping strategies. Other features include Bi-directional Associations, Association Filtering, Collections of Basic Types, Indexed Collections, CompositeCollection Elements, and Lifecycle Objects.
    • Simple API’s - includes Simple Core API forapplication code, ODMG3-style API as an alternative to the more expressive native API, Extension API to allow customization, and Metadata API for applications that require access to Hibernate’s persistence metadata.
    • Automatic Primary Key Generation -multiplesynthetic key generation including built-in support for identify (auto-increment) columns, sequences, UUID algorithm, and HI/LO algorithm. Alsoincludes support for application assigned identifiers and composite keys.
    • Object/Relational Mapping Definition -XML mapping documents that bridge the O/R impedance mismatch, define the O/R mapping, andgenerate (and export) database table / constraint creation scripts. Designed tobe edited by hand, the Hibernate O/R mapping DTDs offer a human-readableformat. Hibernate also offers XDoclet support.
    • Caching - the Hibernate Dual-Layer CacheArchitecture (HDLCA) delivers thread safeness, non-blocking data access, session level cache, optional second-level cache, and optional query cache. Hibernate also works well when other applications have simultaneous access tothe database.
    • Ultra-High Performance - includes lazy initiation, outer join fetching, batch fetching, support for optimistic locking with versioning and time stamping, no special database tables, and SQL generated at system initialization time. Hibernate was designed from the ground up to working in a cluster and delivers a highly scalable architecture. Hibernate consistently offers superior performance to straight JDBC coding. Transaction isolation is guaranteed by the manner in which Hibernate integrates with database and JTA transactions.
    • J2EE Integration - Hibernate can be configured andmanaged via JMX. It can also be integrated with J2EE application servers including JBoss Application Server via JCA. Hibernate SessionFactory may be listed in JNDI. Session is serializable and can be kept by a stateful session bean or in a Servlet. Application Server data source may be used to provideJDBC connections. Transactions integrate with application server transactions via JTA.
    • Ability to Run Outside J2EE Container - in order to accelerate the code/test cycle, you can run Hibernate outside of an application server and skip the deployment step. This is a popular feature among developers.
    • Support for Wide Range of Databases -including Oracle, DB2, Sybase, MS SQL Server, PostgreSQL, MySQL, HypersonicSQL, MckoiSQL, SAP DB, Interbase, Pointbase, Progress, FrontBase, Ingres, Informix, andFirebird.

      Now the hard question: How much will I save with Hibernate?

      To answer this question you need to look at the Hibernate with two different lenses. First, for the short term the advantages are clear: less code, less defects, standard-compliance, and higher performance. On the long run, the advantages are even clearer. Future versions of J2EE EJB technologies will be based on Hibernate and companies utilizing it today will have a relative advantage in the field.

      Now, let me try to summarize the previously discussed items and quantify the gains in a dollar amount.

      I will start with a hypothetical team ready to use Hibernate in a pilot project.The team has 10 developers, none of which has any previous Hibernate experience. To support the developers the management brings in two consultants mainly to train and mentor developers during project inception, design and construction. The company decides to implement a second project with similar Level of Effort (LOE). In the second case there is no need for training andthus the company frees their consultants.

       

       

       

       

        In-house persistence framework    Hibernate - First Project    Hibernate - Second Project    Average of two projects 
        A    Number of developers    10    10    10    10 
        B    Number of consultants    0    2    0    1 
        C    Developer $ cost/hr    $65    $65    $65    $65 
        D    Consultant $ cost/hr    0    $130    0    $65 
        E    Number of persistent classes    100    100    100    100 
        F    Lines of Code (LOC)/class (avg)    600    400    400    400 
        G    LOE (persistent classes only)    3000 hrs    2000 hrs    2000 hrs    2000 hrs 
        H    LOE (training)/developer    0 hrs    40 hrs    0     20
       

       

       

       

       

       

       

       

       

       

       

       

       

       

        Total (G*C + A*B*H*D)    $195,000    $234,000    $130,000    $182,000 

      Looking at these empirical numbers it is easy to spot the advantage of Hibernate. Just in two short projects the tangible costs are significantly lower than those ofthe in-house solution. There are also some intangible benefits in the above scenario, such as:

      • Recruiting personnel already familiar with an industry-standard tool is easier and cheaper
      • New recruits do not need to learn any proprietary persistence frameworks
      • Company value is increased because of its compliance to standards

      Conclusion

      No matter how long the list of technical features, there will always be costs associated with open-source project adoption. Just as with any new initiative, there will be some visible and some hidden costs which need special attention.

      For many open-source projects, the visible costs are minimal, while the chunk ofthe hidden cost is related to personnel training and retention. Open-source projects and Hibernate in particular seem to be well aware of this fact as theymake special efforts to provide their “customers” with quality documentation. Documentation […and the lack of it] has become an important cost factor affecting the mitigation of another cost factor - personnel training. Hence many open-source projects are benchmarked on the amount and quality of their documentation.

      Second important factor in the cost analysis is the amount of time spent chasing defects in the product. With paid software [in most cases] enterprises have the leverageof immediate and [mostly] reliable technical support. With the emerging new market of open-source support, this becomes less of a factor.

      Third, licensing issues and fear of litigation is still a big obstacle for the adoption of open-source by corporations. Company lawyers are the most likely group to oppose any open-source infusion into the enterprise from the simple fear of litigation. Licensing education is an important item on the open-source community’s agenda.

      Hibernate makes a great case of cost mitigation for most of these factors.