Tuesday, March 20, 2007

Ode to Hibernate



At each of my first two jobs I wrote an object-relational mapping framework in Java. The first was an abomination, the second merely rotten. I'm not the only engineer to have traveled this road. You write some code to generate SQL for your simple CRUD operations, you get one-to-many relationships working, and then you (and probably the rest of your team) spend a couple of months piling on hacks to support outer joins, many-to-many relationships, and all the other "extras" that are of course not "extras" at all. So imagine my mood the day a coworker introduced me to Hibernate (thanks Toby!). Just a few days of prototyping made it clear that Hibernate was an elegant solution to a hard problem, and that I would never again feel compelled to build an OR Mapping framework in Java. Joy.

As a fan of Hibernate it gives me great pleasure to announce the open-source availability of Hibernate Shards, a framework that adds support for horizontal partitioning (or in Google parlance, "sharding") to Hibernate Core. There are a number of reasons you might not keep all your data in a single relational database. Maybe you have too much data. Maybe a potential customer won't sign up for your service unless her company's data lives in its own database. Whatever your reasons, dealing with a sharded dataset adds complexity to the development and management of your application. Hibernate Shards is designed to encapsulate and reduce the complexity of building applications that work with sharded datasets.

I worked with Tomislav Nad and Maulik Shah (fellow Googlers who share my enthusiasm for Hibernate and Java infrastructure) to build Hibernate Shards as a 20 percent project. We think what we have now will be useful to the Java community, but this is most certainly not a polished release. There are functionality gaps to be filled, design warts to be smoothed, and bugs to be shaken out. We look forward to working with you as we address these issues and make Hibernate Shards even more powerful in the months to come. If you'd like to read more please visit the official Hibernate Shards website.

Happy Sharding!

13 comments:

  1. Hi, do you have a version for shards in JDK 1.4.x ?

    Thanks,

    Gavin

    ReplyDelete
  2. Hi Gavin,

    Unfortunately no, we don't have a 1.4 compatible version. Shards makes fairly heavy use of enums, generics, and the concurrency libraries, all of which were introduced in 1.5. It would of course be possible to rewrite Shards without these language features and libraries, but we don't have any plans to do so. Please let me know if you have more questions.

    Thanks,
    Max

    ReplyDelete
  3. Hi Max-

    Looks like there hasn't been a release of shards since 8/07. Is the project dead?

    ReplyDelete
  4. Hi Max,

    I have posted a comment in the forums in Hibernate and I was wondering if I could get your opinion on the use of a Sharded Session with Hibernate Search.

    From a high level perspective I am trying to an architechture using Memcached , Hibernate Search with a single index, and a sharded DB.

    I have done this using Spring/Hibernate using MVC and DAO design pattern for data access, with pure hibernate implementations and the initial prototype works performs extremely well.

    Now enter hibernate sharding and the wheels are coming off!

    My first blow came from my extensive use of DetachedCriteria.

    My design all stems from a base object with a shardid in all object hierarchies, and a constraint ensuring all objects descended from that base object will be in the same shard. So I subclassed DetachedCriteria and using a factory based on entity type I can retirve the shard I need, which ias restrictive but works for me.

    I am now busy with the FullTextSession and I am taking hits.

    Basically EventSource isnt supported by shards and a ShardedSessionImplementor and a SessionImplementor are quite different.

    Its statrting to look like a bit of an intractable problem, and I was wondering if you had given it any thought or if there are any plans to introduce some form of compatibility.

    ReplyDelete
  5. Hi, what is involved in getting Shards to support lazy loading.

    Do you think is realistic that at some point it will be supported

    ReplyDelete
  6. When is the next stable production version of Hibernate Shards?

    ReplyDelete
  7. hi Max,

    i read about hibernate shard and i didn't find enough information on it. is latest version of hibernate shard release? or is the project dead?
    I have to use sharding in my project, is there any other way to use sharding using hibernate or other?

    Thanks,
    Sudhanshu

    ReplyDelete
  8. Hibernate has many features to support ORM requirements and recently I found a page where many information about Hibernate is present at

    http://hibernate-questions.weebly.com

    ReplyDelete
  9. Hi, I am interested in JPA integration of Shards; I won't be using Query features, as long as I can inject something into EJB as EntityManager it's fine.

    In a posting on Hib. Forums you mention you have some code for this. Can I take a look at it?

    ReplyDelete
  10. What do u meant by Ode???

    ReplyDelete
  11. hi
    I am using hiberbate , i got error
    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.

    how to solve it
    Thanks
    Arun

    ReplyDelete
  12. Hi Max,
    Is it possible to integrate Hibernate Shards with Spring?

    ReplyDelete
  13. hibernate config (автоматическое создание таблиц) http://blog.malphas.ru/index.php/archives/87
    Здесь можно найти еще инфы по hibernate, та же там есть статья про пагинацию hibernate. Это не реклама, просто кому интересно может почитать

    ReplyDelete