Re: Testing Spring + Cayenne Integration / Architectural Doubts

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

  • Next message: Gary Affonso: "Re: Status of MySQL AUTO_INCREMENT Support?"

    Hi, Andrus,


           As you saw, I'm not so expert in Architecture Patterns, ORM, Ant and Spring. I'm just learning a bit of them.

           I really like Cayenne. With it, I can make complex things work fine in a simple and fast way. And is exactly because of that I'm trying to bring it to our development team. But before, I need to show and convince the people that it is the best choice. And a possible requirement that could be defined here is the possibility of to have the freedom of the ORM layer, without DTO's. I need some suggestions how to do it, if possible.

           I think it would be nice the idea of "POJO DataObjects". How could it be done and When? In the truth, part of our team is fearing to face a little problem we have before. Let me explain it:

            Our project was built at a "old Java generation fashion (1999 - 2001)" by another team. The persistence layer framework was hand-written (DAO like). We use 28 Session Stateless EJB and XML/XSL presentation layer. We didn't use DTO classes. In the presentation layer, often there was a direct reference to the Persistent Entities. We are trying to update and fix some practices.

            Some months ago, we had to make our first WebService, becoming available a lot of EJB methods to a .NET application. The most of our EJB methods deal with classes of the Businness Model, which in our case, were the same Persistent Entities. And these Persistent Entities extend from some frameworks classes. When we generate the WSDL
    interface file, we should include the description of the persistence framework classes. (We used the WSAD 5.1.2 wizards). To avoid that problem, we had to create a lot of DTO's and some conversion methods to deal with the WebService's request/response. If we could have free model classes that were automatically (ORM) persisted, it will be very good for us, at least.

           I don't know if I'm explaining correctly and If it could be possible. Maybe I'm thinking wrong and wanting so much :-D . Sorry.

           Thanks,

    André Luiz
       




    Andrus Adamchik wrote:

    Hello!
    
      
    The only hard problem I had was to implement a Servlet
    Filter to bind DataContexts to the ThreadLocal.
        
    
    You can use an example from Cayenne Pet Store bundled with the preview
    integration. It does just that.
    
    Now Spring architecture...
    
    I am not a big expert in Spring either and haven't looked at Equinox or
    AppFuse. But I like Spring a lot. Though not necessarily for all the
    advertised reasons. For all of its cool stuff I noticed that it tends to
    encourage people to build features into their business applications that
    they don't need... just becase they can. (I am not referring to your case
    as I don't know enough about it, besides it seems like the bigger the
    system the bigger the value that Spring can provide)
    
    Anyway... why is extending a framework class so bad? Because some guy on
    TSS said so? This is his opinion/preference. Even if you think that at
    some point in the future you want to migrate from Cayenne to something
    else, you can still do it "with an ant script". Actually you can even use
    cgen Ant task to regenerate your _* classes to extend something else. Or
    use a common superclass from the beginning, e.g. MyPersistentObject
    extends CayenneDataObject. Then if you switch the framework you just
    change this one class's superclass.
    
      
    make all Businness Model as interfaces,
    and each ORM provide the classes with its own features and
    implement the Model interfaces
        
    
    This is a possible solution, but I think it is an overkill. I guarantee
    you you will spend more time implementing that compared to any future
    migration from Cayenne.
    
      
    Is there a easy and elegant strategy in Cayenne to convert
    DataObjects to simple POJO's? (something like attach/deattach
    objects/entities).
        
    
    I am actually thinking of providing POJO DataObjects at some point as this
    seems to be a big marketing point these days. But please note that the
    main benefit of Cayenne (unlike some other ORM) is that you don't have to
    attach/detach anything! An associtaion of a DataObject with DataConext is
    what gives you this smooth ride with relationships, faults and other
    performance and usability features.
    
    Hope this didn't sound too much like propaganda :-) I am convinced that
    your goal of keeping all layers above DAO independent from the ORM
    implementation is actually achievable.
    
    Cheers
    Andrus
    
    
    
    
      



    This archive was generated by hypermail 2.0.0 : Tue Jan 18 2005 - 15:50:29 EST