Version 1

    Product Evaluation FAQ

    This page is intended to answer common questions asked by people evaluating Hibernate. It answers both technical and non-technical questions about the Hibernate product.


    Does Hibernate implement a standard?

    Hibernate is an open source de facto standard, similar to Struts or log4j. By the very nature of being open source, Hibernate users are not vulnerable to vendor lock-in. Hibernate is the most popular ORM solution for any programming language, and was responsible for the popularization of ORM technology in Java.


    The Hibernate team was and is deeply involved in the development of the EJB 3.0 (JSR-220) persistence specification, which takes inspiration from a number of key features of Hibernate. The JBoss EJB 3.0 implementation is built on top of Hibernate. A standalone implementation of EJB 3.0 persistence is available with Hibernate Annotations and Hibernate EntityManager, both run inside and outside of JBoss Application Server (or with all other application servers). Built on the Hibernate Core, you get a fully standards compatible, future proof, and mature persistence solution.


    Now that EJB 3.0 is out, is Hibernate dead?

    Certainly not! We got involved in EJB 3.0 because we wanted to bring ORM technology to the masses. The EntityManager API defined by JSR-220 is just an alternative way to call Hibernate, from our point of view. We hope and expect that the standardization of ORM as a central, integrated piece of the J2EE platform will drive the next wave of adoption of ORM and Hibernate.


    Because the standards process is an inappropriate place to innovate new functionality, and because it takes several years to validate a new idea and then work it into a final specification document, we will continue to develop and innovate our own APIs and use them to provide cutting edge features to those users for whom portability is not a major priority. For example, we are providing the cool new filtering functionality via the traditional Hibernate Session interface. In time, new features that prove sufficiently important will probably find their way into the EJB spec.


    Is Hibernate "unsupported"?

    JBoss Inc. sponsors the development of Hibernate by employing several members of the Hibernate developer team. JBoss Inc. provides Hibernate-specific development and production support contracts with service levels up to 24x7 with a 2 hour response time. The Hibernate team, together with other JBoss Inc. support engineers, is committed to providing an outstanding level of service to support customers.


    Is Hibernate "under-documented"?

    Hibernate ships with a 220 page reference user manual (in six languages). If that's not enough, there is a 400 page book, Hibernate in Action, written by two members of the Hibernate team, and several other books about Hibernate from various authors. Dozens of tutorials, demo applications, and presentations are freely available (and linked on the Hibernate website). Hibernate is the most documented ORM solution ever.


    Is Hibernate easy to use?

    Nothing in persistence is easy. But Hibernate is much, much easier to use than handwritten SQL/JDBC. And it is much, much easier to use, and much more powerful, than EJB 2.1 entity beans.


    Is Hibernate mature?

    Hibernate is now more than five years old (founded in 2001) and is absolutely rock solid. The Hibernate3 core is over 76 000 lines of Java code, together with 36 000 lines of Java unit test code. Hibernate is used by tens of thousands of Java projects worldwide. About 25 000 developers are registered on the Hibernate forums (including international forums for German, French, Chinese, and Russian speakers). An average of 150 questions are asked (and answered!) on the community forums every day, 360 days a year. Hibernate is downloaded about 3000 times every day. These numbers - unlike marketing numbers shown by competing commercial software vendors - are easily verifiable by anyone (just check our SourceForge project page).


    What if JBoss turns evil and creates a commercial fork of Hibernate?

    Hibernate is licensed under the terms of the LGPL. The LGPL is different to Apache or BSD style licenses in that it effectively disallows the creation of a closed-source fork. This protects the Hibernate community as well as any contributors to Hibernate. Anyone who wanted to release Hibernate under a different license would have to obtain permission from hundreds of people who have contributed code to Hibernate, which would be impractical. Hibernate is and will be free software.


    Can I embed Hibernate in my commercial application?

    Yes, usage of the unmodified distributed Hibernate binary has no restrictions. However, if you change Hibernate in any way and recompile the source, you must make those changes available to your users, under the same license terms as Hibernate (i.e. the LGPL).


    Why isn't Hibernate used for the EJB 3.0 Reference Implementation?

    The license terms of the Java EE Reference Implementation are incompatible with the LGPL. As much as we would like  to see Hibernate used in the RI, we just can't do it either legally or morally. JBoss and the Hibernate team are committed to all terms of the LGPL license.


    What is the best application framework for use with Hibernate?

    The Hibernate team designed and created JBoss Seam  as a next-generation application framework for use with ORM technology (Hibernate and/or EJB 3.0). Seam solves several ORM-specific problems (to do with persistence context management) that are not solved by traditional pure request-oriented application frameworks.


    Aren't stored procedures always faster than dynamic SQL?

    No. Hibernate always executes SQL statements using a JDBC PreparedStatement, which allows the database to cache the query plan. There is no reason to avoid the use of generated SQL in modern applications.


    Won't my application run slower if I use Hibernate?

    Most users who have ported an application from handwritten SQL/JDBC to Hibernate report a huge reduction in code, and an enormous increase in performance. Hibernate is able to implement certain optimizations (caching, outer join association fetching, JDBC batching, etc.) much more efficiently than typical handwritten JDBC.


    More importantly, if you write your application using ORM, you'll save so much effort that you'll have much more time left over to hand-tune the approximately 1% of cases which do benefit from handwritten JDBC.


    Does Hibernate have a GUI?

    The Hibernate Tools subproject is a major initiative to develop a comprehensive suite of Eclipse plugins and Ant tasks for development of Hibernate and EJB 3.0 POJO-based domain models. Hibernate Tools includes modules for: Hibernate mapping file editing, database reverse engineering, interactive query prototyping, and more. Stay tuned for more news about this project.


    How can I use Hibernate in a J2EE environment?

    You may use Hibernate from servlets or Struts actions, or from behind an EJB session bean facade. In a CMT environment, Hibernate integrates with JTA Datasources and the TransactionManager, as well as JNDI. With Hibernate EntityManager and Hibernate Annotations you can use Hibernate in a JEE 5.0 environment today.


    Does Hibernate implement connection pooling?

    Hibernate ships with two open source connection pools that have been thoroughly tested by the Hibernate team and are in use in production in thousands of Hibernate applications. Of course, in a J2EE environment, we recommend that you configure Hibernate to use the application server Datasource.


    Does Hibernate implement prepared statement caching?

    Prepared statement caching is a responsibility of the connection pool. If your connection pool implements prepared statement caching (most do), then Hibernate will take advantage of that.


    Does Hibernate implement attribute-level lazy fetching?

    Hibernate uses proxies generated at system initialization time to implement lazy fetching of associations. This is a basic feature of any ORM solution; Hibernates implementation has the advantage of not requiring any build-time processing - an essential feature for agile development.


    Hibernate also supports lazy fetching of any attribute via instance variable interception. This feature requires use of a build-time bytecode enhancer (an Ant task). We don't believe that this feature is very useful in most applications and we have often shown that every use case can be implemented in a more elegant and robust way.


    Does Hibernate fully support polymorphism?

    Hibernate supports polymorphic queries and associations in all three inheritance mapping strategies (and even allows mixing of the two most important strategies). In this respect, Hibernate3 is more sophisticated than what is offered by most commericial vendors at this time.


    Does Hibernate have "fetch plans"?

    Yes, as part of a much more sophisticated feature. Hibernate's criteria query API can be used to do express what some products call a "fetch plan", and much, much more.


    Does Hibernate have "fetch profiles"?

    No. We consider "fetch profiles" to be an inelegant workaround for the limitations of other ORM query languages. It would be trivial for us to implement fetch profiles in Hibernate but nobody would ever use them. Hibernate users don't ask for this feature because they have much more flexible mechanisms available, built into Hibernate's query facility.


    Does Hibernate support a clustered cache?

    Hibernate has a very sophisticated second-level cache architecture (we encourage you to read up on it as part of your evaluation), and supports pluggable cache implementations. Read-only, time-based invalidation, as well as full transactional concurrency control strategies are available for cache tuning on an per entity and per association basis. Hibernate ships with several open source cache implementations, for local and distributed cluster usage, and you can integrate your own quite easily, just by implementing an interface.


    Does Hibernate support a query result set cache?

    Yes. The query cache may even be used in a clustered environment, as long as the underlying second-level cache implementation uses clustered replication (one of the included cache implementations does).


    Does Hibernate support handwritten SQL?

    In Hibernate 3.0, any generated SQL statement may be overridden in the Hibernate mapping metadata. Hibernate also supports queries expressed in the native SQL dialect of the underlying database and offers facilities to integrate them cleanly into your application without creating dependencies. In practice, most users find that they need these features much less often than they expect.


    In addition, Hibernate allows definition of "derived" entities and derived attributes, where a class or property maps to a SQL select or SQL formula embedded in the mapping document.


    Does Hibernate support stored procedures?

    Yes. This is just a special case of the handwritten SQL support.


    Does Hibernate support composite keys?

    Absolutely. All Hibernate 3.0 functionality works just as well for data models with natural keys (including composite keys) as it does for models with surrogate keys.


    Does Hibernate support (my favorite association style here)?

    Please refer to the "Association mapping" chapter of the Hibernate 3.0 user manual for an overview of supported association mappings. (The answer is probably "yes", we support just about everything.)


    Is Hibernate appropriate for use with legacy data?

    A major goal of Hibernate 3.0 was better support for "crazy" legacy data models. We think we've got excellent support for most legacy and even broken data models. However, we always encourage our users to clean up and improve their schemas whenever possible.


    Is Hibernate suitable for use in batch/bulk processing?

    Hibernate has always focussed upon solving problems affecting typical OLTP use cases. This is reasonable, since the overwhelming bulk of all persistence-related code written in Java deals with OLTP scenarios.


    More recently, users have requested functionality for dealing with the kinds of problems that commonly occur in offline batch processing. Hibernate 3.1 will introduce a raft of new features for bulk processing.


    Can Hibernate persist instance variables directly?

    Yes. Hibernate can also persist JavaBeans-style properties via getter and setter methods, which we prefer, but it's up to you. You can also plug-in your own access strategy.


    Does Hibernate support monitoring?

    Hibernate 3.0 exposes a wide range of performance-related statistics via JMX and a native Statistics interface if JMX is not available.


    You get what you pay for, right? How can a free product possibly be as good as a commercial product that costs money?

    Because open source works. Hibernate is no half-baked "free alternative". Indeed, we see it as a more sophisticated solution than the commercial competition. The Hibernate team, which includes several full-time, professional developers, dedicated to the Hibernate project, is committed to maintaining this technical leadership.


    Should I believe what commercial vendors tell me about Hibernate?

    Definitely not. At least one commercial competitor has made extremely misleading claims about Hibernate to potential customers and on their website. Feel free to fact-check their assertions by posting on the Hibernate user forum, or, if you are a prospective services customer, emailing