RES: Cayenne vs Hibernate

From: Andre Luiz do Nascimento Sousa (andresous..aixaseguros.com.br)
Date: Tue Jun 21 2005 - 15:29:31 EDT

  • Next message: Pirola Davide: "thanksgiving"

    Hi All,
     
     
            I work at a small financial system. Currently, we have a simple data layer based on DAO pattern. We are trying to start a subproject to change this data layer and some points of our design. We work with IBM DB2 v. 7.2 and WSAD-IE 5.1.1. We have 21 session stateless EJB's and the system expose some methods as WebServices to a Java and old an ASP 3.0 client application (through a DLL done in .NET). We are using Struts as framework presentation layer.
     
            We don't have too much experience in ORM and architectural design patterns. So we are studying the ORM concepts, knowing and testing some ORM tools. I started with Cayenne and I really appreciated it. But I've found a problem with Cayenne. How was said, we expose some Web Services and at this method signatures, we use some objects from domain model, which are the persistent objects. And by the fact that in Cayenne there's a need of each domain object to extend from "CayenneDataObject", when we generate the WebServices stuff in WSAD all the tree of the domain object is included in the WSDL files, bringing a lot of underised effort.
     
            We would wish to have domain objects be referenced at any layer, without the need to reference/import some specific API ORM tool class. We are facing this same problem with our actual DAO framework. In a new architectural approach we're trying to reach (using Spring IoC), we need that our domain objects were dealed as simple POJO's, without subclassing any ORM class.
     
            To solve that issue, I attempted to implement a converter between layers, transforming the persistent objects in DTO's and vice-versa. But for Cayenne objects, I had a problem when setting/getting the "DataContext" and "persistentState" properties from one kind to another (BeanUtils).
     
            Then we tried to use Hibernate 2.1.8 and 3.0.5. They promised to persist simple POJO's, and it seems to be true. We've got to make the same domain object to "travel" along the layers, avoiding "class duplicity" and extra conversions. However, we have to deal with attach/deattach objects from Session and lazy fetches configuration. Another problem is the lack of a GUI Modeler and Generator, as CayenneModeler.
     
            We are still at evaluation phase. I'd like to know If Cayenne has some new thoughts about supporting simple POJO's or If there are some new suggestions about our problem here.
     
            Sorry for the bad english : (
     
            Thanks a lot.
     
     
    André Luiz do Nascimento Sousa<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
    * scout23d..oowy.com
    ' (55 0XX61) ...

    -----Mensagem original-----
    De: Joel Trunick [ mailto:joel.trunic..ebifysolutions.com]
    Enviada em: terça-feira, 21 de junho de 2005 13:28
    Para: cayenne-use..bjectstyle.org
    Assunto: RE: Cayenne vs Hibernate

    I haven't used Hibernate 3.0, only the previous versions, but here's my
    take:

    1) Cayenne - Better exception handling. Hibernate's framework is awful,
    exposing SQLExceptions and the like, you need Spring just to hide all
    its checked exceptions (or write catches all day long). The messages
    weren't any good anyway. Cayenne OTOH will say "field to large for
    database column", not give some cryptic message that it couldn't store a
    record.

    2) Cayenne - Working criteria API. This is critical in my mind
    especially for a rich domain model (criteria api is espoused by Eric
    Evans/Martin Fowler). Hibernate's (last time I used it) had support that
    wasn't usable (couldn't do a count, or paged query with it. I think it's
    "kind of" supported now, not sure). It had a less Java friendly API
    anyway for paging, Cayenne will give you a normal java.util.List that
    could fault in objects as you access the list (the count is simply the
    list size), without using a special API.

    3) Cayenne - Cayenne Base Object. Your objects know their object id's,
    whether they are persisted. I can serialize the object id's and get the
    objects back without knowing what their key is. It makes the object
    model richer and more straightforward in my opinion. POJOs are
    overrated, it's not like they save you code, it seems all Hibernate
    projects end up with some sort of BaseEntity object (that at least
    defines an ID for all objects), and implements a Hibernate interface to
    do onLoad, onSave stuff (Hibernate folks are in denial about POJOs). Oh
    yeah, and Cayenne generates the property name strings for you as
    constants so you can use them in your quieries, a simple bug eliminator.

    Oh yeah, I don't miss seeing the "Lazy Initialization" error in
    Hibernate.

    4) The Cayenne way is a bit different, it only stores object types, not
    primitives _directly_. You have to write your accessors to convert
    from/to primitives. This fits with what I like anyway (see Streamlined
    Object Modeling). I make the Cayenne superclass with protected accessors
    by default (so only a rich domain model is exposed). So, in short, its
    different, but not necessarily worse. Most types seem supported (such as
    BigDecimal), but DateTime is lacking clean support.

    5) The Cayenne modeler. In my mind this can go either way. The GUI is
    "neat", and can save you some simple mistakes by having it validate, but
    on the other hand, I wouldn't mind having other off-the-shelf ways to
    muck with the XML (maybe XDoclet, annotations, or other). Out of these
    items, this hasn't been a big factor for me.

    Joel

    -----Original Message-----
    From: Mike Kienenberger [ mailto:mkienen..laska.net]
    Sent: Tuesday, June 21, 2005 10:19 AM
    To: cayenne-use..bjectstyle.org
    Subject: Cayenne vs Hibernate

    I'm interested in hearing a comparison of Cayenne and Hibernate by any
    former
    or current Hibernate users.

    What strengths does Cayenne have over Hibernate?

    If possible, give your level of experience with Hibernate (Hibernate
    versions used, months of use, or whatever metric you think is
    reasonable).

    Thanks!

    -Mike



    This archive was generated by hypermail 2.0.0 : Tue Jun 21 2005 - 15:43:40 EDT