Re: RES: INSERT without specifying an parameter.

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Feb 02 2005 - 10:55:10 EST

  • Next message: Andrus Adamchik: "Re: RES: INSERT without specifying an parameter."

    Hi Reinaldo,

    What is the full definition of the table? How is the sequence being invoked?

    > Oracle's sequence

    Oracle or Postgres?

    > No, what I want is that, when cayenne sends the query "INSERT...", it
    > doesn't send the ID parameter That is because I want to use Oracle's
    > sequence, and not Cayenne's sequence manager.

    Starting from 1.2 M1 (and M2 that will be released shortly) you can mark a
    column as "auto" or "generated" (the label name is still changing in the
    modeler as we are still working on this feature)... This will result in
    suppressing this column from INSERT.

    However you need to understand the limitation of this approach. When you
    insert an object, Cayenne needs to know its ObjectId to be able to
    continue handling such object properly after the insert is committed. This
    means that whatever value is generated by the DB, it has to be passed back
    to Cayenne and matched with the original object.

    MySQL and SQLServer support that for "autoincrement" columns via new JDBC3
    feature... However I am not aware of other DBs/drivers properly passing
    back generated values, so there is no clean way of handling that... I
    guess one workaround would be to invalidate and refetch all freshly
    inserted objects after commit... Not very efficient though...

    Andrus

    > -----Mensagem original-----
    > De: Gentry, Michael (Contractor) [mailto:michael_gentr..anniemae.com]
    > Enviada em: quarta-feira, 2 de fevereiro de 2005 13:25
    > Para: cayenne-use..bjectstyle.org
    > Assunto: RE: INSERT without specifying an parameter.
    >
    >
    > Are you wanting to manually manage the INSERT statements yourself
    > instead of let Cayenne handle the database for you?
    >
    > -----Original Message-----
    > From: Reinaldo Coelho Sartorelli [mailto:reinaldo.sartorell..ES.com]
    > Sent: Wednesday, February 02, 2005 10:21 AM
    > To: cayenne-use..bjectstyle.org
    > Subject: INSERT without specifying an parameter.
    >
    >
    > I'd like to execute an INSERT without specifying an ID parameter, how
    > can I do this in Cayenne?
    >
    >
    > For example:
    > Table(ID INT, NAME VARCHAR2(30))
    >
    > Insert into Table('TEST');
    > Insert into Table('Jon Smit');
    >
    >
    >
    > As my ID field is a default SEQUENCE, my program shouldn't need to pass
    > the ID...
    >
    > PS: Itīs run in a POSTGRESQL
    >
    >
    > Tks,
    > Reinaldo.
    >
    > ________________________________________________________________________
    > This communication is for use by the intended recipient and contains
    > information that may be privileged, confidential or copyrighted under
    > law. If you are not the intended recipient, you are hereby formally
    > notified that any use, copying or distribution of this e-Mail, in whole
    > or in part, is strictly prohibited. Please notify the sender by return
    > e-Mail and delete this e-Mail from your system. Unless explicitly and
    > conspicuously stated in the subject matter of the above e-Mail, this
    > e-Mail does not constitute a contract offer, a contract amendment, or an
    > acceptance of a contract offer. This e-Mail does not constitute consent
    > to the use of sender's contact information for direct marketing purposes
    > or for transfers of data to third parties.
    >
    > This email has been scanned for all viruses by the MessageLabs service.
    >
    > ________________________________________________________________________
    > This email has been scanned for all viruses by the MessageLabs service.
    >
    > ________________________________________________________________________
    > This communication is for use by the intended recipient and contains
    > information that may be privileged, confidential or copyrighted under
    > law. If you are not the intended recipient, you are hereby formally
    > notified that any use, copying or distribution of this e-Mail, in whole
    > or in part, is strictly prohibited. Please notify the sender by return
    > e-Mail and delete this e-Mail from your system. Unless explicitly and
    > conspicuously stated in the subject matter of the above e-Mail, this
    > e-Mail does not constitute a contract offer, a contract amendment, or an
    > acceptance of a contract offer. This e-Mail does not constitute consent
    > to the use of sender's contact information for direct marketing purposes
    > or for transfers of data to third parties.
    >
    > This email has been scanned for all viruses by the MessageLabs service.



    This archive was generated by hypermail 2.0.0 : Wed Feb 02 2005 - 10:55:11 EST