Re: Cayenne 1.2 + PostgreSQL

From: Cris Daniluk (cris.danilu..mail.com)
Date: Fri Dec 09 2005 - 17:19:03 EST

  • Next message: Gentry, Michael \(Contractor\): "RE: Cayenne 1.2 + PostgreSQL"

    I was under the impression that if you didn't specify sequences, it
    would fall back to AUTO_PK_SUPPORT, but either way, I can definitely
    see your point.

    The DataNode seems like an awkward location for me. Really, its part
    of the DbAdapter, so putting PkGenerator in the same configuration
    view is almost misleading.

    I don't really think the modeler is the right place for this. I was
    about to say its easy to do with a custom configuration, but when I
    went to whip up a quick example, I realized that the new AutoAdapter
    stuff makes it next to impossible :)

    You can always do this:

            cayenneConfiguration.setLoaderDelegate(new
    RuntimeLoadDelegate(cayenneConfiguration, cayenneConfiguration
                    .getLoadStatus()) {

                protected void initAdapter(DataNode node, String adapterName) {

                    node.setAdapter(new PostgresAdapter() {

                        protected PkGenerator createPkGenerator() {
                            return CustomPkGenerator();
                        }

                    });
                }

            });

    But I'd definitely agree that its less than ideal, as it hardcodes the
    adapter and bypasses the AutoAdapter. I still think it should be done
    via code, but maybe there could be a delegate that is passed to the
    adapter... users may also want to specify alternate ActionBuilders,
    etc. The DbAdapter implementations have a lot of hardcoded classes
    now.

    public interface DbAdapterDelegate {

      PkGenerator createPkGenerator();

      SQLActionVisitor createSQLActionVisitor();

      // maybe others...

    }

    On 12/9/05, Kevin Menard <kmenar..ervprise.com> wrote:
    >
    > On 12/9/05 2:32 PM, "Cris Daniluk" <cris.danilu..mail.com> wrote:
    >
    > > In all the confusion of this issue, I've lost track of what the
    > > intended goal here is :)
    > >
    > > As of now, 1.2 supports postgres sequences with no problems. Can you
    > > summarize what you want to accomplish on top of this?
    >
    > Sure thing.
    >
    > What I'd like to be able to do is specify a PKGenerator implementation in
    > the DataNode, much like how one can provide a custom DbAdapter. I think the
    > original problem was that in 1.2 we went from using PK tables to using
    > sequences. People that relied on the old behavior were sort of left out in
    > the cold. If the PkGenerator implementation was pluggable though, then we
    > would ship with both an implementation of the old behavior and the new
    > sequence-based one. In principle, switching between the two would be as
    > simple as selecting a different one in the modeler.
    >
    > Additionally, it seems periodically people integrating with legacy databases
    > have peculiar requirements about how their PKs must be generated. Here,
    > allowing them to specify their own PkGenerator implementation would let them
    > do what they need without too much hassle.
    >
    > Make more sense now? Or am I trying to fix a non-issue?
    >
    > --
    > Kevin
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Dec 09 2005 - 17:19:05 EST