Discussions

News: TSS Article: Object Relational Mapping with Cayenne

  1. Andrus Adamchik and Eric Schneider present Cayenne - an open source Object Relational Mapping (ORM) framework. Cayenne is an integrated suite that includes modeling and deployment tools. This article introduces some of Cayenne's features, and shows how to quickly create an ORM application.

    Read Cayenne: Being Productive with Object Relational Mapping

    Threaded Messages (19)

  2. I like the looks of this.[ Go to top ]

    It seems wel done on first glance. Has anyone compared it with Hibernate, on a feature-by-feature basis, as well as looking at how the two perform? Is there a direct code comparison from the client side?
  3. distributed cache[ Go to top ]

    So, does the distributed cache make any attempt to coordinate updates, or is it a simple last-save-wins approach? It seems like all of the open source distributed cache systems work that way, except for the JBoss one that uses JTA transactions.
  4. distributed cache[ Go to top ]

    You are right - we do not attempt to implement our own distributed transactions. If you need them, use container features - Cayenne allows that.

    I personally prefer "disconnected" objects and optimistic locking to some sort of coordinated distributed long running transaction monstrosity. Staying as simple and lightweight as your system allows...

    Andrus
  5. I like the looks of this.[ Go to top ]

    Is there a direct code comparison from the client side?

    I would like to see one myself, as this is being asked pretty often. Besides it is always good to know your own strengths and weeknesses compared to others.

    My opinion (actually expressed in the article pretty well) is that ORM in Java is quickly reaching a point of becoming a commodity meaning that most of the first tier tools have all the needed features. So it all comes down to the flavor... :-)

    Andrus
  6. Cayenne vs. Hibernate[ Go to top ]

    public class _Artist extends org.objectstyle.cayenne.CayenneDataObject {...

    ..that's one advantage of Hibernate over Cayenne!
    Of course otherwise Cayenne may have better/easier qualities over Hibernate.
  7. Cayenne and session replication[ Go to top ]

    One of the problems I had with cayenne (I'm using 1.0 release) is that it doesn't allow deploying with session replication. What happens is that cayenne sessions seem to be locked with database connections. Now, if one servlet container dies and the other tries to use the replicated cayenne objects it gives a "global exception" because the db connection is not valid.
    It also happen when (I tried it for testing purpose) the db is shut down and restarted.
    Also, when this happen, cayenne cannot be reset in any way, you have to reset your app server/servlet container.
    Has anyone found a workaround for this?
  8. One of the problems I had with cayenne (I'm using 1.0 release)
    > is that it doesn't allow deploying with session replication.

    Session replication should work just fine, even in 1.0. A number of Cayenne applications were deployed using replication. So if you have any problems, please submit a bug report with details via JIRA on our site.


    > What happens is that cayenne sessions seem
    > to be locked with database connections.

    This is strange - the whole point is that DataContext is "disconnected", so it can be deserialized and attached to any other Cayenne stack.

    Andrus
  9. ... the whole point is that DataContext is "disconnected", so it can be deserialized and attached to any other Cayenne stack. Andrus
    Ok, the problem was probably in storing DataObjects in session (for caching purposes). I think I should just avoid doing this, correct?
  10. Ok, the problem was probably in storing DataObjects in session (for caching purposes). I think I should just avoid doing this, correct?
    Well, I can see how this can screw up deserialization in theory. If you have concrete examples with exception stack, please still open a bug report.

    Andrus
  11. I like the looks of this.[ Go to top ]

    Kudos to Andrus Adamchik and Eric Schneider. This is really great stuff.

    Nice to have an alternative to Hibernate which, imho, is going the wrong way as JBoss will drive its development from now on.

    Hurray for simplicity.
  12. happy user[ Go to top ]

    Having experience with WebObjects/EOF, I started using cayenne one year ago. It was really easy to get started, and I think it is a lot better than EOF. Cayenne is more straight forward than EOF and the open source nature of cayenne is gold.

    I am currently using cayenne in two projects. One developed from the ground up with cayenne and one project upgraded to cayenne that did not use a ORM at all. I will use cayenne in my next projects as well.

    The code is robust and the developers are really fixing bugs! My favorite new function in cayenne 1.1 is the new cache for all DataContexts inside a single java vm. I am not using the shared cache. The feature I am missing most is the ability to prefetch across a flattened many-to-many relationship.
  13. happy user[ Go to top ]

    +1 from me ... as an ex-WO user, I've been using Cayenne in combination with Tapestry and am very happy with it.
  14. Use with Spring?[ Go to top ]

    Any thought of use with the Spring framework like Hibernate or iBATIS?
  15. Use with Spring?[ Go to top ]

    Cayenne can be used with Spring pretty much out of the box. Cayenne has its own access stack, configured via CayenneModeler. All that is needed is to "mount" a Configuration object singleton in Spring, and use it as a source of DataContexts for sessions. I may write a simple factory making the process more transparent, unless somebody contributes it before I do it :-)

    I guess more complex scenarios may benefit from some of the Spring features. I can think of automatically assigning an appropriate DataDomain to a user session based on some security token. But then 99% of Cayenne apps just use a single DataDomain.

    Andrus
  16. Use with Spring?[ Go to top ]

    BTW, we just started a discussion of that on cayenne-user:

    http://objectstyle.org/cayenne/lists/cayenne-user/2004/06/0028.html

    If you have any ideas, please jump in.
  17. el[ Go to top ]

    Have you considered to release Cayenne expression language independently? It would make an alternative to OGNL and XPath (as used by Jakarta JXPath).
    Cayenne looks nice. I'll play with it. Thanks for the article.
  18. el[ Go to top ]

    I actually like Cayenne expressions package a lot. This is my personal favorite feature in Cayenne 1.1. Among other things it allowed us to refactor (throw out) tons of internal code that was doing manual property and metadata navigation.

    Well, sometimes I think that a standalone expressions distro is a good idea. But my current opinion is that it is not worth it (and I haven't heard otherwise from other committers). There are a few reasons:

    1. I personally have no interest in maintaining such standalone package, and have no goal to compete with OGNL. I'd rather continue developing Cayenne and compete with Hibernate :-)

    2. There are cool "db:" expressions, that probably don't make sense outside Cayenne.

    3. The scope of the expressions package actually maps to common SQL conditions and arithmetic operations.

    So there is a synergy with the rest of Cayenne, and making it more generic than it is may hurt that.

    Andrus
  19. my experience has been good[ Go to top ]

    I've been using Cayenne with Tapestry, and I am quite pleased with it. The architecture feels quite elegant to me, the mailing list is friendly and helpful, and bugs are rare (and fixed quickly in any case).
  20. It seems to me that Cayenne is one of the "invasive" bunch of persistence mechanisms. It requires your data objects to inherit from a common superclass and requires them to conform to a particular style (which is most easily produced using their mapping tool). It claims to be able to persist "POJO"s, but they don't mean the same thing as I do when they say that. For me a POJO might look like this:

    class Fred {
        String id;
        String name;
        int value;
    }

    If my persistence tool can persist a POJO then it ought to be able to persist instances of this class unmodified. Hibernate can do this. So can TopLink. Cayenne can't. JDO can (but only by groping my class when I'm not looking).

    Huw