Testing Spring + Cayenne Integration / Architectural Doubts

From: André Luiz do Nascimento Sousa (andresous..aixaseguros.com.br)
Date: Tue Jan 18 2005 - 13:10:15 EST

  • Next message: Andrus Adamchik: "Re: Testing Spring + Cayenne Integration / Architectural Doubts"

    Hi, All,


           I'm doing some tests with the new Cayenne/Spring preview released a few days ago. I'm not a expert in Spring Framework, but I could make it works with cayenne. The only hard problem I had was to implement a Servlet Filter to bind DataContexts to the ThreadLocal. I followed a example application called "Equinox" (https://equinox.dev.java.net), which works with Spring, Hibernate, iBATIS and JDO.

           Our projects here are for a important insurances and financial company. We use a rudimentary and old hand-written persistence framework. We use DB2 v7. Currently, a part of our development team is doing some researches in another ORM frameworks/solutions. The most of us doesn't have a good knowledge in ORM, but we're trying to get that skills. I'm a big fan of Cayenne project, 'cause I've used it in some small personal projects.

           But when we could know and understand the architecture used in the "Equinox" and "AppFuse" project, we tried to build a simple project like that to make tests at some ORM frameworks. By what I could understand, the strategy reached at that project was to use Spring to bind all layers and resources. The business logic and model are kept unchangeable, while the presentation layer can be switched to Struts, JSF, WebWork or Tapestry. The persistence layer can be switched among Hibernate, iBATIS and JDO. All that is done by running some Ant scripts.

           I'm attempting to build a small application where we could have the following layers:

    ==================================
    Presentation Layer (Struts / JSF)  \
    ==================================  \
    Businness Logic (Not EJB)            \
    ==================================    \
    Businness Model (POJO/JavaBeans)       > Binding by Spring Framework style
    ==================================    /
    DAO Interfaces                       /
    ==================================  /
     {ORM Frameworks}                  /
     ------------------------------------------
       Cayenne   |  Hibernate  |  EJB 3.0 (???) ...
     ------------------------------------------

           We're trying don't use the DTO concept. The Model Classes should be able to be referenced freely among the layers. The original Model Class should be at the same time a simple POJO (without extending or implement any ORM specific class or interface) and a persistent entity.

           The problem is that in the Cayenne framework, a DataObject is not a simple POJO. And this compelled us to create DataObject classes layer and a conversion layer to interact with Model Classes. That has worked fine at simple entities, but we're losing in performance and some benefits of the relationships navigation. And I found at the TheServerSide Forum this message on the thread "http://www.theserverside.com/news/thread.tss?thread_id=26498#150034".

           This has left me a little worried about Cayenne choice. My questions are:

    1. Anybody has already met this archtectural case?
    2. Is there another solution? (eg.: make all Businness Model as interfaces, and each ORM provide the classes with its own features and implement the Model interfaces);
    3. Is there a easy and elegant strategy in Cayenne to convert DataObjects to simple POJO's? (something like attach/deattach objects/entities).
           Sorry for the bad english and thanks for the patience and help.

           []'s


    André Luiz - Brasil





    This archive was generated by hypermail 2.0.0 : Tue Jan 18 2005 - 12:08:36 EST