Re: Insert ignore

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jan 11 2005 - 11:35:26 EST

  • Next message: emre: "Error during Configuration initialization"

    Hi Borut,

    As one of Cayenne's goals is maintaining a consistent object graph, it
    doesn't care to support such SQL extentions as INSERT IGNORE. As for how
    to customize this behavior... One way is to create a custom DbAdapter
    inheriting from the DbAdapter you are currently using. This DbAdapter
    would override "createDataNode" to return a custom DataNode subclass. In
    DataNode subclass override "runBatchUpdate" to do a custom query
    translation (probably via a subclass of InsertBatchQueryBuilder)...

    We planned to do some lifecycle events / delegates redesign in 1.2 to make
    Cayenne easier to customize. Your case provides a good example of one
    commonly used customization. I guess we might implement some sort of
    filter (or chain of responsibility) API in the future to make it easier.
    It will work kind of like servlet filters do, allowing to intercept and
    rewrite all SQL operations.

    Andrus

    > Hi again,
    >
    > I have to insert data into a table but with IGNORE modifier for the
    > INSERT statement. Excerpt from the manual says:
    >
    > If you specify the IGNORE keyword in an INSERT with many rows, any rows
    > that duplicate an existing UNIQUE index or PRIMARY KEY value in the
    > table are ignored and are not inserted. If you do not specify IGNORE,
    > the insert is aborted if there is any row that duplicates an existing
    > key value.
    >
    > So my goal is: INSERT IGNORE INTO MY_TABLE (NAME, SURNAME)
    > VALUES('xxxxx', 'yyyyy')
    >
    > How to do this in Cayenne?
    >
    > -Borut



    This archive was generated by hypermail 2.0.0 : Tue Jan 11 2005 - 11:35:28 EST