Re: sql server pk generation ??

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jan 26 2010 - 02:57:41 EST

  • Next message: camon..ynet.com: "Re : sql server pk generation ??"

    MSDE is a variation of the SQLServer. Not even sure if the auto-
    adapter detection works for it, as we don't have it in our test matrix
    (watch the logs when the adapter is blank - Cayenne prints which
    adapter it is planning to use). But setting SqlServerAdapter is the
    safest thing to do.

    > when custom adapter is SqlServerAdapter exception is
    >
    >  org.apache.cayenne.CayenneRuntimeException: [v.3.0RC1 Dec 27
    > 2009
    > 11:45:54] One and only one PK row is expected, instead got 0

    The PK column in the table must be setup as auto increment. Or
    alternatively you should use "default" PK generation strategy and
    create needed stored procedures from CayenneModeler:

    http://cayenne.apache.org/doc30/generate-primary-key-support.html

    Andrus

    On Jan 26, 2010, at 12:42 AM, camon..ynet.com wrote:
    > hi all...
    >
    > i use cayenne 3.0RC1 , msde, jdbc driver is jtds-1.2.5...
    >
    > I mapped db tables and  set the primary key generation from
    > database by
    > modeller.(database generated)
    >
    > all selects returned successfull... but when i insert a row there is a
    > problem...
    >
    > exceptions :
    >
    > if custom adapter  is blank or JdbcAdapter or
    > SysbaseAdapter 
    > then
    >
    > Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
    > [v.3.0RC1 Dec 27 2009 11:45:54] Commit Exception
    >     at
    > org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:
    > 1134)
    >     at
    > org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:
    > 1045)
    >     at Main.main(Main.java:78)
    > Caused by: java.sql.SQLException: Cannot insert explicit value for
    > identity column in table 'CARIGEN' when IDENTITY_INSERT is set to OFF.
    >     at
    > net
    > .sourceforge
    > .jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
    >     at
    > net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
    >
    > ...................
    >
    > when custom adapter is SqlServerAdapter exception is
    >
    >  org.apache.cayenne.CayenneRuntimeException: [v.3.0RC1 Dec 27
    > 2009
    > 11:45:54] One and only one PK row is expected, instead got 0
    >
    >
    > i tried cayenne-1.2 but same result...
    >
    > any suggestion ?
    >  
    >
    >
    >
    > _______________________________________________
    >
    >
    > Nilüfer 'Zalimin Kararı' şarkısı ile ilk defa ve sadece
    > kavun'da! Tıkla,
    > Dinle!
    >



    This archive was generated by hypermail 2.0.0 : Tue Jan 26 2010 - 02:58:15 EST