Re: Cayenne and Spring (a Hibernate inspired question)

From: Robert Zeigler (robert..uregumption.com)
Date: Wed Feb 27 2008 - 09:34:32 EST

  • Next message: Robert Zeigler: "on hibernate vs. cayenne"

    I've personally avoided Hibernate, so I can't speak to the spring/
    hibernate stuff, sorry.

    For sorting across multiple relationships, if you want to do it in-
    memory, you can always use cayenne's "Ordering".
    You can add multiple orderings to any particular query, and you can
    also use multiple orderings on an in-memory list.
    For example:

    //sort an in-memory list of enrollments by the associated students'
    lastName then firstName
    List<Ordering> orders = Arrays.asList(
            new Ordering("student.lastName",true),
            new Ordering("student.firstName",true));

    Ordering.orderList(enrollments,orders);

    //fetch a list of enrollments from the db, pre-ordered by the
    associated student lastname and firstname

    SelectQuery query = new SelectQuery(Enrollment.class);
    query.addOrdering("student.lastName",true);
    query.addOrdering("student.firstName",true);

    DataContext.getThreadDataContext().performQuery(query);

    You can also create queries in the modeler tool, which supports adding
    multiple orderings.

    HTH,

    Robert

    On Feb 27, 2008, at 2/277:51 AM , Kevin Menard wrote:

    > Hi Marek,
    >
    > My Hibernate experience is limited to a single project that did not
    > use
    > Spring, so it's hard for me to draw a fair comparison. My take from
    > passively watching on discussion lists (particularly the Tapestry one)
    > is that Spring makes Hibernate usable in a way that Cayenne is out of
    > the box. It seems you know this already, though.
    >
    > In a Web app I have here, we an account creation operation split up
    > over
    > three screens and it involves several different entities. For this, I
    > simply used a peer context per page and coalesce everything at the
    > end.
    > This is a little bit older code and I would likely use a child context
    > for it now. The reason I did it this way is that while conceptually a
    > single operation, completing any of the phases is a complete
    > transaction. If you want to enforce start to finish behavior, you
    > could
    > use a single context shared via session. Just watch yourself because
    > it's a lot harder to enforce a workflow through a browser than it is
    > through Swing.
    >
    > As for sorting across multiple relationships, I guess I would have to
    > understand a little more as to what you want to do. Simplest thing is
    > to write your own Comparator, but you may want to look at mapping a
    > query, and barring that, use SQLTemplate to achieve what you need in
    > the
    > DB.
    >
    > I hope that helps.
    >
    > --
    > Kevin Menard
    > Servprise International, Inc.
    > Remote reboot & power control for your network
    > www.servprise.com +1 508.892.3823 x308
    >
    >
    >> -----Original Message-----
    >> From: Marek Wawrzyczny [mailto:marek_wawrzyczn..nternode.on.net]
    >> Sent: Tuesday, February 26, 2008 7:14 AM
    >> To: use..ayenne.apache.org
    >> Subject: Cayenne and Spring (a Hibernate inspired question)
    >>
    >> Hi,
    >>
    >> It has been a while since I last used Cayenne and that was within a
    >> Swing ROP
    >> context.
    >>
    >> More recently I have been involved in writing a Spring MVC/Hibernate
    >> application. The experience has only made me fonder for Cayenne and
    > now
    >> it
    >> appears that the team I'm in may consider ORM alternatives.
    >>
    >> My application is relatively simple CRUD application with the
    > exception
    >> of one
    >> set of two screens, where all data entry culminates in a parent/child
    >> interface (using Spring's AbstractWizardFormController ).
    >>
    >> The object graph can become somewhat complex, combining objects from
    >> about 10
    >> different entities. The pages ideally would require a long-running
    >> session,
    >> or rather a ObjectContext spanning several requests.
    >>
    >> I'm curious as to how well does Cayenne handle these types of
    >> interfaces in
    >> web applications.
    >>
    >> The other problem we're currently having is sorting across multiple
    >> relationships.
    >>
    >> I'm curious as to other people's experiences in this area. I would
    > love
    >> to be
    >> able to convince the team to move to Cayenne if the framework fits
    >> the
    >> bill.
    >>
    >>
    >> Kind regards,
    >>
    >> Marek Wawrzyczny



    This archive was generated by hypermail 2.0.0 : Wed Feb 27 2008 - 09:35:11 EST