cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: sql server pk generation ??
Date Tue, 26 Jan 2010 07:57:41 GMT
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
>
> &nbsp;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, camone@mynet.com wrote:
> hi all...
>
> i use cayenne 3.0RC1 , msde, jdbc driver is jtds-1.2.5...
>
> I mapped db tables and&nbsp; 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&nbsp; is blank or JdbcAdapter or  
> SysbaseAdapter&nbsp;
> then
>
> Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
> [v.3.0RC1 Dec 27 2009 11:45:54] Commit Exception
> &nbsp;&nbsp;&nbsp; at
> org.apache.cayenne.access.DataContext.flushToParent(DataContext.java: 
> 1134)
> &nbsp;&nbsp;&nbsp; at
> org.apache.cayenne.access.DataContext.commitChanges(DataContext.java: 
> 1045)
> &nbsp;&nbsp;&nbsp; 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.
> &nbsp;&nbsp;&nbsp; at
> net 
> .sourceforge 
> .jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
> &nbsp;&nbsp;&nbsp; at
> net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
>
> ...................
>
> when custom adapter is SqlServerAdapter exception is
>
> &nbsp;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 ?
> &nbsp;
>
>
>
> _______________________________________________
> 	
> 	
> 		Nilüfer 'Zalimin Kararı' şarkısı ile ilk defa ve sadece  
> kavun'da! Tıkla,
> Dinle!
> 	


Mime
View raw message