Re: many to many relations and default values for the association table?

From: Marc Guenther (yod..chli.ch)
Date: Mon Oct 04 2010 - 11:00:12 UTC

  • Next message: Borut Bolčina: "SQLTemplate SELECT max(ordering) ClassCastException"

    Hi,

    On 30.09.2010, at 19:55, Andrey Razumovsky wrote:
    > The easiest way is to set the default value at database level. If this way
    > doesn't work for you, here's Cayenne 3 solution, maybe a bit ugly, but the
    > one comes first to my mind:
    > you can intercept low-level SQL query generation by
    > implementing BatchQueryBuilderFactory (extending
    > DefaultBatchQueryBuilderFactory). There you can plug your own
    > InsertBatchQueryBuilder that will set certain fields for certain
    > tables. BatchQueryBuilderFactory can be set via
    > DataDomain.setQueryBuilderFactory.

    I have done this:
      ((DataContext) context).getParentDataDomain().setQueryBuilderFactory(new MyBatchQueryBuilderFactory());
    which in turn sets a MyInsertBatchQueryBuilder.

    Unfortunately, that is only called for inserts into the group and user db_entities, but not for the join table.

    Marc



    This archive was generated by hypermail 2.0.0 : Mon Oct 04 2010 - 11:00:53 UTC