Re: Elementary Question

From: Michael Gentry (mgentr..asslight.net)
Date: Tue Apr 20 2010 - 16:43:19 EDT

  • Next message: Joe Baldwin: "Re: Elementary Question"

    Hi Joe,

    On Tue, Apr 20, 2010 at 1:12 PM, Joe Baldwin <jfbaldwi..arthlink.net> wrote:
    > Michael,
    >
    >> However, I would suggest not doing both strategies on the same table as it will probably bite you in the long run somehow.
    >
    > That is not my intention (but I agree with you).  I am verifying all of my entities right now.  However, the Cayenne Modeler configuration was not clear.  You said that if I set the "PK Generation Strategy" to "Database Generated" but then I unintentionally had the "Create Primary Key Support" checked in the "Generate DB Schema" Options dialog, then it would create the AUTO_PK_SUPPORT table.
    >
    > It is not clear to me why you have this in two separate config parameters.  Base on your explanation (in the previous email), that if you select the "PK Generation Strategy" type for the individual entities, then the "Create Primary Key Support" option should be automatically configured at that time.
    >
    > Said a different way: why would the Cayenne Modeler create Cayenne-Managed Primary Key Support for tables with the "PK Generation Strategy" to "Database Generated"?

    I think you are confusing Cayenne Modeler's schema generation feature
    with Cayenne's runtime primary key support feature. More below.

    > I may be wrong, but base on what you had described, it seems like Cayenne Modeler is creating a conflicting configuration in this scenario.

    There is no conflict. Perhaps if you don't use "Database Generated"
    on any DbEntities then it would be safe in Cayenne Modeler to not have
    the checkbox when generating the SQL to create the AUTO_PK_SUPPORT
    table, but I'm not even sure I agree with that idea. Keep in mind
    that each table can have different PK generation options (even though
    it would potentially be confusing). Cayenne doesn't stop you from
    using the AUTO_PK_SUPPORT on some entities even when you are using
    MySQL's auto-generated PK on other entities (for example, you may need
    higher performance on some tables for bulk inserts). Cayenne will use
    whichever strategy you specify for the entity, but allows you to
    create the AUTO_PK_SUPPORT if it is needed (your call) when you
    generate the SQL.

    >> If you have Cayenne generating the keys, it'll push them to MySQL.
    >
    > I agree, but I have clearly set "PK Generation Strategy" to "Database Generated".  So my question remains: given that the CM allows conflicting parameters, which one takes precedence here?  I have set "PK Generation Strategy" to "Database Generated", are you saying that Cayenne then ignores this configuration?
    >
    >
    >> However, I would suggest not doing both strategies on the same table as it will probably bite you in the long run somehow.
    >
    >
    > I agree.  That is *definitely* not my intention, (But as I described above, it appears that this is very easy to do with CayenneModeler.)
    >
    > Michael, what you have described concerning CM is not intuitive.  I could easily see a designer configuring one table with Cayenne-Managed auto-generation, and another with database-auto-generation (because Cayenne Modeler allows it).  If what you are saying is true, then selecting the "Create Primary Key Support" checkbox, will override they "database-auto-generation" parameter.

    That's actually not at all what I am saying. Selecting the "Create
    Primary Key Support" checkbox in Cayenne Modeler's schema generation
    tool just creates it in the schema. It doesn't override what you set
    for each individual entity. Whomever is doing the design needs to
    decide how the PKs are generated on each table. In a lot of
    applications it is the same method for all entities, but it doesn't
    have to be that way.

    > If this is as bad as you suggest, then Cayenne Modeler should either prevent this from happening or display an explicit warning.

    I don't think it is bad at all and never suggested it was. It is a
    very important and useful feature.

    mrg



    This archive was generated by hypermail 2.0.0 : Tue Apr 20 2010 - 16:44:29 EDT