You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by WONDER <mm...@web.de> on 2006/04/20 15:43:48 UTC

PK problem with Postgre

Hi,

I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501 JDBC 3
and Cayenne 1.2.B2.

I use the Default Strategy to create the PKs using Cayenne. in the DB, i
created the SEQ : pk_TableName. like pk_image for Table image.

Sometimes I get the following error and sometimes it just work.
Till now, I coulding find the logic behind.

Anybody can help?
Thanks.

-------------------------------------------------
Priority : INFO

Class.Method(line):
org.objectstyle.cayenne.access.QueryLogger.logQueryError(QueryLogger.java:43
9)

Message: *** error.

org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
constraint "image_pk"

at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorI
mpl.java:1513)

at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.ja
va:1298)

at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:349)

at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statem
ent.java:2559)

at
org.objectstyle.cayenne.access.jdbc.BatchAction.runAsBatch(BatchAction.java:
164)

at
org.objectstyle.cayenne.access.jdbc.BatchAction.performAction(BatchAction.ja
va:114)

at
org.objectstyle.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAct
ion.java:95)

at org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:309)

at
org.objectstyle.cayenne.access.DataDomainFlushAction.runQueries(DataDomainFl
ushAction.java:255)

at
org.objectstyle.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAc
tion.java:177)

at
org.objectstyle.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:827)

at
org.objectstyle.cayenne.access.DataDomain$2.transform(DataDomain.java:798)

at
org.objectstyle.cayenne.access.DataDomain.runInTransaction(DataDomain.java:8
53)

at org.objectstyle.cayenne.access.DataDomain.onSync(DataDomain.java:795)

at
org.objectstyle.cayenne.access.DataContext.flushToParent(DataContext.java:12
17)

at
org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:11
21)

at
de.mrer.base.CayenneBaseComponent.commitChanges(CayenneBaseComponent.java:65
)

at ImageEditPage.uploadFile(ImageEditPage.java:99)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at
KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAccessor.
java:54)

at
com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKe
yValueCoding.java:1160)

at
com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey
(NSKeyValueCoding.java:1268)

at com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)

at
com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCod
ing.java:498)

at
com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.va
lueForKeyPath(NSKeyValueCodingAdditions.java:212)

at
com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1600)

at
com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOK
eyValueAssociation.java:46)

at
com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton
.java:59)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at
com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
tContent.java:31)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at
com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
tContent.java:31)

at
com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
tContent.java:31)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at
com.webobjects.appserver._private.WOConditional.invokeAction(WOConditional.j
ava:55)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)

at
com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
entReference.java:104)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)

at
com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
entReference.java:104)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)

at
com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
entReference.java:104)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)

at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)

at
com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)

at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
paredPage(WOComponentRequestHandler.java:196)

at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
paredSession(WOComponentRequestHandler.java:287)

at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
paredApplication(WOComponentRequestHandler.java:322)

at
com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(W
OComponentRequestHandler.java:358)

at
com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WO
ComponentRequestHandler.java:432)

at
com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:13
06)

at
com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java
:173)

at
com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254
)

at java.lang.Thread.run(Thread.java:595)


-------- 

Priority : FATAL

Class.Method(line):
de.mrer.base.BaseComponent.validationFailedWithException(BaseComponent.java:
104)

Message: de.mrer.exceptor.CustomException: [v.1.2B2 April 17 2006] Commit
Exception

========================

de.mrer.exceptor.CustomException: [v.1.2B2 April 17 2006] Commit Exception

at
de.mrer.base.CayenneBaseComponent.commitChanges(CayenneBaseComponent.java:74
)

at ImageEditPage.uploadFile(ImageEditPage.java:99)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at
KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAccessor.
java:54)

at
com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKe
yValueCoding.java:1160)

at
com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey
(NSKeyValueCoding.java:1268)

at com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)

at
com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCod
ing.java:498)

at
com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.va
lueForKeyPath(NSKeyValueCodingAdditions.java:212)

at
com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1600)

at
com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOK
eyValueAssociation.java:46)

at
com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton
.java:59)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at
com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
tContent.java:31)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at
com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
tContent.java:31)

at
com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
tContent.java:31)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at
com.webobjects.appserver._private.WOConditional.invokeAction(WOConditional.j
ava:55)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)

at
com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
entReference.java:104)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)

at
com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
entReference.java:104)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)

at
com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
entReference.java:104)

at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
micGroup.java:101)

at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
.java:110)

at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)

at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)

at
com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)

at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
paredPage(WOComponentRequestHandler.java:196)

at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
paredSession(WOComponentRequestHandler.java:287)

at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
paredApplication(WOComponentRequestHandler.java:322)

at
com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(W
OComponentRequestHandler.java:358)

at
com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WO
ComponentRequestHandler.java:432)

at
com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:13
06)

at
com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java
:173)

at
com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254
)

at java.lang.Thread.run(Thread.java:595)

-------------------------------------------------


Re: PK problem with Postgre

Posted by Lindsay Steele <ls...@iinet.net.au>.
Andrus Adamchik wrote:
>
> create sequence foo_bar_seq;
> create table foo (bar integer unique not null default 
> nextval('foo_bar_seq'));
>
Yes,  I am using this way.

> (Or is this something else?) The example above does not work with 
> Cayenne because Postgres driver as of 8.0 does not implement 
> Statement.getGeneratedKeys() thus making it impossible (ok, rather 
> very hard) for Cayenne to retrieve the key generated in such way. The 
> solution - do not tie a PK column to a sequence in Postgres, let 
> Cayenne generate the key.
Maybe that explains things. I migrated from mysql so was hoping - or 
expecting it would work the same.

> I guess we may implement an equivalent of 
> 'Statement.getGeneratedKeys()' on Cayenne end by using Postgres 
> proprietary API to retrieve generated keys (and thus enable scenario 
> (1)), still I hoped the driver would provide that.
>
> Andrus
>
 Ok,  I understand that you need to know the generated key once a record 
is entered - which makes sense.

For now .. I did some more testing and will stick with my previous strategy.




Re: PK problem with Postgre

Posted by WONDER <mm...@web.de>.
Indeed using the custom SEQ solved the problem. "At least till now".
I belive that Cayenne does not use the seq always using the Default
strategy.
i.e:
first insert Cayenne reads the seq. I see this in the log, where Cayenne
executes the SEQ. another time Cayenne doesnot executes the SEQ.

I think, its good idea if cayenne always uses the same strategy, and its
very good idea to make Cayenne create the needed Sequences if they does not
exist. I dont see any reason, why to do not create the seq automatically
using Cayenne and default strategy.

peaSakoe


----- Original Message ----- 
From: "Andrus Adamchik" <an...@objectstyle.org>
To: <ca...@incubator.apache.org>
Sent: Friday, April 21, 2006 8:26 AM
Subject: Re: PK problem with Postgre


>
> On Apr 21, 2006, at 4:42 AM, lsteele@iinet.net.au wrote:
> >
> >  When I was looking at the SQL statements Cayenne was using, it was
> > constantly
> > trying to include the id - thus causing problems with Postgres's
> > autoincrement.
> >
> >  They seemed to think that Cayenne should just insert the record
> > and let
> > postgres worry about doing the autoincrement.
>
> This thread seems to be about two separate things - (1)
> autoincremented column values and (2) sequences used by Cayenne to
> generate PK. These are two different strategies (as mentioned in one
> of the messages that you quoted). Cayenne most certainly works with
> the second scenario (I am constantly using postgres myself)...
>
> > In postgres, if  you want autoincrement you set the sequences up
> > and then you
> > just insert a record without trying to predict what the next id
> > will be.
> > Postgres should look after this.
>
> Regarding the first scenario - can you elaborate how you setup your
> tables? One way that I know is this:
>
> create sequence foo_bar_seq;
> create table foo (bar integer unique not null default nextval
> ('foo_bar_seq'));
>
> (Or is this something else?) The example above does not work with
> Cayenne because Postgres driver as of 8.0 does not implement
> Statement.getGeneratedKeys() thus making it impossible (ok, rather
> very hard) for Cayenne to retrieve the key generated in such way. The
> solution - do not tie a PK column to a sequence in Postgres, let
> Cayenne generate the key.
>
> I guess we may implement an equivalent of 'Statement.getGeneratedKeys
> ()' on Cayenne end by using Postgres proprietary API to retrieve
> generated keys (and thus enable scenario (1)), still I hoped the
> driver would provide that.
>
> Andrus
>
>
>
>
>


Re: PK problem with Postgre

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Apr 21, 2006, at 4:42 AM, lsteele@iinet.net.au wrote:
>
>  When I was looking at the SQL statements Cayenne was using, it was  
> constantly
> trying to include the id - thus causing problems with Postgres's  
> autoincrement.
>
>  They seemed to think that Cayenne should just insert the record  
> and let
> postgres worry about doing the autoincrement.

This thread seems to be about two separate things - (1)  
autoincremented column values and (2) sequences used by Cayenne to  
generate PK. These are two different strategies (as mentioned in one  
of the messages that you quoted). Cayenne most certainly works with  
the second scenario (I am constantly using postgres myself)...

> In postgres, if  you want autoincrement you set the sequences up  
> and then you
> just insert a record without trying to predict what the next id  
> will be.
> Postgres should look after this.

Regarding the first scenario - can you elaborate how you setup your  
tables? One way that I know is this:

create sequence foo_bar_seq;
create table foo (bar integer unique not null default nextval 
('foo_bar_seq'));

(Or is this something else?) The example above does not work with  
Cayenne because Postgres driver as of 8.0 does not implement  
Statement.getGeneratedKeys() thus making it impossible (ok, rather  
very hard) for Cayenne to retrieve the key generated in such way. The  
solution - do not tie a PK column to a sequence in Postgres, let  
Cayenne generate the key.

I guess we may implement an equivalent of 'Statement.getGeneratedKeys 
()' on Cayenne end by using Postgres proprietary API to retrieve  
generated keys (and thus enable scenario (1)), still I hoped the  
driver would provide that.

Andrus





Re: PK problem with Postgre

Posted by ls...@iinet.net.au.
I was a while back, but it went like this. 

In postgres, if  you want autoincrement you set the sequences up and then you 
just insert a record without trying to predict what the next id will be. 
Postgres should look after this.

 When I was looking at the SQL statements Cayenne was using, it was constantly
trying to include the id - thus causing problems with Postgres's autoincrement.  

 They seemed to think that Cayenne should just insert the record and let
postgres worry about doing the autoincrement.

 I am just happy it works though .. not a big deal.

Quoting Bryan Lewis <br...@maine.rr.com>:

> Surprise to me.  I use Postgres frequently and didn't run into any
> problems or custom sequences.  I often switch between Oracle and
> Postgres without changing the default PK generation.  My Postgres
> sequences are routine, created like so:
> 
> create sequence pk_tablename
>   INCREMENT 20 MINVALUE 1 START 200 CACHE 1;
> 
> Why do the Postgres developers suspect Cayenne?
> 
> 
> Lindsay Steele wrote:
> 
> > With Postgres,  I found that I had to use a Custom Sequence - then put
> > in the sequence name and then use a Cached PK Size of 1.
> >
> > This wasn't exactly intuitive and Postgres developers think Cayenne
> > has issues - but it does seem to work.
> >
> >
> > WONDER wrote:
> >
> >> Hi,
> >>
> >> I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501
> >> JDBC 3
> >> and Cayenne 1.2.B2.
> >>
> >> I use the Default Strategy to create the PKs using Cayenne. in the DB, i
> >> created the SEQ : pk_TableName. like pk_image for Table image.
> >>
> >> Sometimes I get the following error and sometimes it just work.
> >> Till now, I coulding find the logic behind.
> >>
> >> Anybody can help?
> >> Thanks.
> >>
> >> -------------------------------------------------
> >> Priority : INFO
> >>
> >> Class.Method(line):
> >>
> org.objectstyle.cayenne.access.QueryLogger.logQueryError(QueryLogger.java:43
> >>
> >> 9)
> >>
> >> Message: *** error.
> >>
> >> org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
> >> constraint "image_pk"
> >>
> >> at
> >>
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorI
> >>
> >> mpl.java:1513)
> >>
> >> at
> >>
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.ja
> >>
> >> va:1298)
> >>
> >> at
> >>
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:349)
> >>
> >>
> >> at
> >>
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statem
> >>
> >> ent.java:2559)
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.jdbc.BatchAction.runAsBatch(BatchAction.java:
> >>
> >> 164)
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.jdbc.BatchAction.performAction(BatchAction.ja
> >>
> >> va:114)
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAct
> >>
> >> ion.java:95)
> >>
> >> at
> >> org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:309)
> >>
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.DataDomainFlushAction.runQueries(DataDomainFl
> >>
> >> ushAction.java:255)
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAc
> >>
> >> tion.java:177)
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:827)
> >>
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.DataDomain$2.transform(DataDomain.java:798)
> >>
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.DataDomain.runInTransaction(DataDomain.java:8
> >>
> >> 53)
> >>
> >> at org.objectstyle.cayenne.access.DataDomain.onSync(DataDomain.java:795)
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.DataContext.flushToParent(DataContext.java:12
> >>
> >> 17)
> >>
> >> at
> >>
> org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:11
> >>
> >> 21)
> >>
> >> at
> >>
> de.mrer.base.CayenneBaseComponent.commitChanges(CayenneBaseComponent.java:65
> >>
> >> )
> >>
> >> at ImageEditPage.uploadFile(ImageEditPage.java:99)
> >>
> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>
> >> at
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> >>
> >> )
> >>
> >> at
> >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> >>
> >> .java:25)
> >>
> >> at java.lang.reflect.Method.invoke(Method.java:585)
> >>
> >> at
> >>
> KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAccessor.
> >>
> >> java:54)
> >>
> >> at
> >>
> com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKe
> >>
> >> yValueCoding.java:1160)
> >>
> >> at
> >>
> com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey
> >>
> >> (NSKeyValueCoding.java:1268)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)
> >>
> >> at
> >>
> com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCod
> >>
> >> ing.java:498)
> >>
> >> at
> >>
> com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.va
> >>
> >> lueForKeyPath(NSKeyValueCodingAdditions.java:212)
> >>
> >> at
> >>
> com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1600)
> >>
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOK
> >>
> >> eyValueAssociation.java:46)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton
> >>
> >> .java:59)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> >>
> >> tContent.java:31)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> >>
> >> tContent.java:31)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> >>
> >> tContent.java:31)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOConditional.invokeAction(WOConditional.j
> >>
> >> ava:55)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> >>
> >> entReference.java:104)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> >>
> >> entReference.java:104)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> >>
> >> entReference.java:104)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
> >>
> >> at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)
> >>
> >> at
> >>
> com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)
> >>
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> >>
> >> paredPage(WOComponentRequestHandler.java:196)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> >>
> >> paredSession(WOComponentRequestHandler.java:287)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> >>
> >> paredApplication(WOComponentRequestHandler.java:322)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(W
> >>
> >> OComponentRequestHandler.java:358)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WO
> >>
> >> ComponentRequestHandler.java:432)
> >>
> >> at
> >>
> com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:13
> >>
> >> 06)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java
> >>
> >> :173)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254
> >>
> >> )
> >>
> >> at java.lang.Thread.run(Thread.java:595)
> >>
> >>
> >> --------
> >> Priority : FATAL
> >>
> >> Class.Method(line):
> >>
> de.mrer.base.BaseComponent.validationFailedWithException(BaseComponent.java:
> >>
> >> 104)
> >>
> >> Message: de.mrer.exceptor.CustomException: [v.1.2B2 April 17 2006]
> >> Commit
> >> Exception
> >>
> >> ========================
> >>
> >> de.mrer.exceptor.CustomException: [v.1.2B2 April 17 2006] Commit
> >> Exception
> >>
> >> at
> >>
> de.mrer.base.CayenneBaseComponent.commitChanges(CayenneBaseComponent.java:74
> >>
> >> )
> >>
> >> at ImageEditPage.uploadFile(ImageEditPage.java:99)
> >>
> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>
> >> at
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> >>
> >> )
> >>
> >> at
> >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> >>
> >> .java:25)
> >>
> >> at java.lang.reflect.Method.invoke(Method.java:585)
> >>
> >> at
> >>
> KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAccessor.
> >>
> >> java:54)
> >>
> >> at
> >>
> com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKe
> >>
> >> yValueCoding.java:1160)
> >>
> >> at
> >>
> com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey
> >>
> >> (NSKeyValueCoding.java:1268)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)
> >>
> >> at
> >>
> com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCod
> >>
> >> ing.java:498)
> >>
> >> at
> >>
> com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.va
> >>
> >> lueForKeyPath(NSKeyValueCodingAdditions.java:212)
> >>
> >> at
> >>
> com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1600)
> >>
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOK
> >>
> >> eyValueAssociation.java:46)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton
> >>
> >> .java:59)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> >>
> >> tContent.java:31)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> >>
> >> tContent.java:31)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> >>
> >> tContent.java:31)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOConditional.invokeAction(WOConditional.j
> >>
> >> ava:55)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> >>
> >> entReference.java:104)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> >>
> >> entReference.java:104)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> >>
> >> entReference.java:104)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> >>
> >> micGroup.java:101)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> >>
> >> .java:110)
> >>
> >> at
> >> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
> >>
> >> at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)
> >>
> >> at
> >>
> com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)
> >>
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> >>
> >> paredPage(WOComponentRequestHandler.java:196)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> >>
> >> paredSession(WOComponentRequestHandler.java:287)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> >>
> >> paredApplication(WOComponentRequestHandler.java:322)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(W
> >>
> >> OComponentRequestHandler.java:358)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WO
> >>
> >> ComponentRequestHandler.java:432)
> >>
> >> at
> >>
> com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:13
> >>
> >> 06)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java
> >>
> >> :173)
> >>
> >> at
> >>
> com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254
> >>
> >> )
> >>
> >> at java.lang.Thread.run(Thread.java:595)
> >>
> >> -------------------------------------------------
> >>
> >>
> >>   
> >
> >
> 



Re: PK problem with Postgre

Posted by Bryan Lewis <br...@maine.rr.com>.
Surprise to me.  I use Postgres frequently and didn't run into any
problems or custom sequences.  I often switch between Oracle and
Postgres without changing the default PK generation.  My Postgres
sequences are routine, created like so:

create sequence pk_tablename
  INCREMENT 20 MINVALUE 1 START 200 CACHE 1;

Why do the Postgres developers suspect Cayenne?


Lindsay Steele wrote:

> With Postgres,  I found that I had to use a Custom Sequence - then put
> in the sequence name and then use a Cached PK Size of 1.
>
> This wasn't exactly intuitive and Postgres developers think Cayenne
> has issues - but it does seem to work.
>
>
> WONDER wrote:
>
>> Hi,
>>
>> I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501
>> JDBC 3
>> and Cayenne 1.2.B2.
>>
>> I use the Default Strategy to create the PKs using Cayenne. in the DB, i
>> created the SEQ : pk_TableName. like pk_image for Table image.
>>
>> Sometimes I get the following error and sometimes it just work.
>> Till now, I coulding find the logic behind.
>>
>> Anybody can help?
>> Thanks.
>>
>> -------------------------------------------------
>> Priority : INFO
>>
>> Class.Method(line):
>> org.objectstyle.cayenne.access.QueryLogger.logQueryError(QueryLogger.java:43
>>
>> 9)
>>
>> Message: *** error.
>>
>> org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
>> constraint "image_pk"
>>
>> at
>> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorI
>>
>> mpl.java:1513)
>>
>> at
>> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.ja
>>
>> va:1298)
>>
>> at
>> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:349)
>>
>>
>> at
>> org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statem
>>
>> ent.java:2559)
>>
>> at
>> org.objectstyle.cayenne.access.jdbc.BatchAction.runAsBatch(BatchAction.java:
>>
>> 164)
>>
>> at
>> org.objectstyle.cayenne.access.jdbc.BatchAction.performAction(BatchAction.ja
>>
>> va:114)
>>
>> at
>> org.objectstyle.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAct
>>
>> ion.java:95)
>>
>> at
>> org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:309)
>>
>>
>> at
>> org.objectstyle.cayenne.access.DataDomainFlushAction.runQueries(DataDomainFl
>>
>> ushAction.java:255)
>>
>> at
>> org.objectstyle.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAc
>>
>> tion.java:177)
>>
>> at
>> org.objectstyle.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:827)
>>
>>
>> at
>> org.objectstyle.cayenne.access.DataDomain$2.transform(DataDomain.java:798)
>>
>>
>> at
>> org.objectstyle.cayenne.access.DataDomain.runInTransaction(DataDomain.java:8
>>
>> 53)
>>
>> at org.objectstyle.cayenne.access.DataDomain.onSync(DataDomain.java:795)
>>
>> at
>> org.objectstyle.cayenne.access.DataContext.flushToParent(DataContext.java:12
>>
>> 17)
>>
>> at
>> org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:11
>>
>> 21)
>>
>> at
>> de.mrer.base.CayenneBaseComponent.commitChanges(CayenneBaseComponent.java:65
>>
>> )
>>
>> at ImageEditPage.uploadFile(ImageEditPage.java:99)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
>>
>> )
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
>>
>> .java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:585)
>>
>> at
>> KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAccessor.
>>
>> java:54)
>>
>> at
>> com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKe
>>
>> yValueCoding.java:1160)
>>
>> at
>> com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey
>>
>> (NSKeyValueCoding.java:1268)
>>
>> at
>> com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)
>>
>> at
>> com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCod
>>
>> ing.java:498)
>>
>> at
>> com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.va
>>
>> lueForKeyPath(NSKeyValueCodingAdditions.java:212)
>>
>> at
>> com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1600)
>>
>>
>> at
>> com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOK
>>
>> eyValueAssociation.java:46)
>>
>> at
>> com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton
>>
>> .java:59)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
>>
>> tContent.java:31)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
>>
>> tContent.java:31)
>>
>> at
>> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
>>
>> tContent.java:31)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver._private.WOConditional.invokeAction(WOConditional.j
>>
>> ava:55)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>>
>> at
>> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
>>
>> entReference.java:104)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>>
>> at
>> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
>>
>> entReference.java:104)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>>
>> at
>> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
>>
>> entReference.java:104)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>>
>> at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)
>>
>> at
>> com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)
>>
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
>>
>> paredPage(WOComponentRequestHandler.java:196)
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
>>
>> paredSession(WOComponentRequestHandler.java:287)
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
>>
>> paredApplication(WOComponentRequestHandler.java:322)
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(W
>>
>> OComponentRequestHandler.java:358)
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WO
>>
>> ComponentRequestHandler.java:432)
>>
>> at
>> com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:13
>>
>> 06)
>>
>> at
>> com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java
>>
>> :173)
>>
>> at
>> com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254
>>
>> )
>>
>> at java.lang.Thread.run(Thread.java:595)
>>
>>
>> --------
>> Priority : FATAL
>>
>> Class.Method(line):
>> de.mrer.base.BaseComponent.validationFailedWithException(BaseComponent.java:
>>
>> 104)
>>
>> Message: de.mrer.exceptor.CustomException: [v.1.2B2 April 17 2006]
>> Commit
>> Exception
>>
>> ========================
>>
>> de.mrer.exceptor.CustomException: [v.1.2B2 April 17 2006] Commit
>> Exception
>>
>> at
>> de.mrer.base.CayenneBaseComponent.commitChanges(CayenneBaseComponent.java:74
>>
>> )
>>
>> at ImageEditPage.uploadFile(ImageEditPage.java:99)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
>>
>> )
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
>>
>> .java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:585)
>>
>> at
>> KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAccessor.
>>
>> java:54)
>>
>> at
>> com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKe
>>
>> yValueCoding.java:1160)
>>
>> at
>> com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey
>>
>> (NSKeyValueCoding.java:1268)
>>
>> at
>> com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)
>>
>> at
>> com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCod
>>
>> ing.java:498)
>>
>> at
>> com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.va
>>
>> lueForKeyPath(NSKeyValueCodingAdditions.java:212)
>>
>> at
>> com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1600)
>>
>>
>> at
>> com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOK
>>
>> eyValueAssociation.java:46)
>>
>> at
>> com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton
>>
>> .java:59)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
>>
>> tContent.java:31)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
>>
>> tContent.java:31)
>>
>> at
>> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
>>
>> tContent.java:31)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver._private.WOConditional.invokeAction(WOConditional.j
>>
>> ava:55)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>>
>> at
>> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
>>
>> entReference.java:104)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>>
>> at
>> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
>>
>> entReference.java:104)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>>
>> at
>> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
>>
>> entReference.java:104)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
>>
>> micGroup.java:101)
>>
>> at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
>>
>> .java:110)
>>
>> at
>> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>>
>> at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)
>>
>> at
>> com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)
>>
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
>>
>> paredPage(WOComponentRequestHandler.java:196)
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
>>
>> paredSession(WOComponentRequestHandler.java:287)
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
>>
>> paredApplication(WOComponentRequestHandler.java:322)
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(W
>>
>> OComponentRequestHandler.java:358)
>>
>> at
>> com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WO
>>
>> ComponentRequestHandler.java:432)
>>
>> at
>> com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:13
>>
>> 06)
>>
>> at
>> com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java
>>
>> :173)
>>
>> at
>> com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254
>>
>> )
>>
>> at java.lang.Thread.run(Thread.java:595)
>>
>> -------------------------------------------------
>>
>>
>>   
>
>


Re: PK problem with Postgre

Posted by Lindsay Steele <ls...@iinet.net.au>.
With Postgres,  I found that I had to use a Custom Sequence - then put 
in the sequence name and then use a Cached PK Size of 1.

 This wasn't exactly intuitive and Postgres developers think Cayenne has 
issues - but it does seem to work.


WONDER wrote:
> Hi,
>
> I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501 JDBC 3
> and Cayenne 1.2.B2.
>
> I use the Default Strategy to create the PKs using Cayenne. in the DB, i
> created the SEQ : pk_TableName. like pk_image for Table image.
>
> Sometimes I get the following error and sometimes it just work.
> Till now, I coulding find the logic behind.
>
> Anybody can help?
> Thanks.
>
> -------------------------------------------------
> Priority : INFO
>
> Class.Method(line):
> org.objectstyle.cayenne.access.QueryLogger.logQueryError(QueryLogger.java:43
> 9)
>
> Message: *** error.
>
> org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
> constraint "image_pk"
>
> at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorI
> mpl.java:1513)
>
> at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.ja
> va:1298)
>
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:349)
>
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statem
> ent.java:2559)
>
> at
> org.objectstyle.cayenne.access.jdbc.BatchAction.runAsBatch(BatchAction.java:
> 164)
>
> at
> org.objectstyle.cayenne.access.jdbc.BatchAction.performAction(BatchAction.ja
> va:114)
>
> at
> org.objectstyle.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAct
> ion.java:95)
>
> at org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:309)
>
> at
> org.objectstyle.cayenne.access.DataDomainFlushAction.runQueries(DataDomainFl
> ushAction.java:255)
>
> at
> org.objectstyle.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAc
> tion.java:177)
>
> at
> org.objectstyle.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:827)
>
> at
> org.objectstyle.cayenne.access.DataDomain$2.transform(DataDomain.java:798)
>
> at
> org.objectstyle.cayenne.access.DataDomain.runInTransaction(DataDomain.java:8
> 53)
>
> at org.objectstyle.cayenne.access.DataDomain.onSync(DataDomain.java:795)
>
> at
> org.objectstyle.cayenne.access.DataContext.flushToParent(DataContext.java:12
> 17)
>
> at
> org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:11
> 21)
>
> at
> de.mrer.base.CayenneBaseComponent.commitChanges(CayenneBaseComponent.java:65
> )
>
> at ImageEditPage.uploadFile(ImageEditPage.java:99)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> )
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> .java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
>
> at
> KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAccessor.
> java:54)
>
> at
> com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKe
> yValueCoding.java:1160)
>
> at
> com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey
> (NSKeyValueCoding.java:1268)
>
> at com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)
>
> at
> com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCod
> ing.java:498)
>
> at
> com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.va
> lueForKeyPath(NSKeyValueCodingAdditions.java:212)
>
> at
> com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1600)
>
> at
> com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOK
> eyValueAssociation.java:46)
>
> at
> com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton
> .java:59)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> tContent.java:31)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> tContent.java:31)
>
> at
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> tContent.java:31)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at
> com.webobjects.appserver._private.WOConditional.invokeAction(WOConditional.j
> ava:55)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>
> at
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> entReference.java:104)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>
> at
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> entReference.java:104)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>
> at
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> entReference.java:104)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>
> at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)
>
> at
> com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> paredPage(WOComponentRequestHandler.java:196)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> paredSession(WOComponentRequestHandler.java:287)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> paredApplication(WOComponentRequestHandler.java:322)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(W
> OComponentRequestHandler.java:358)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WO
> ComponentRequestHandler.java:432)
>
> at
> com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:13
> 06)
>
> at
> com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java
> :173)
>
> at
> com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254
> )
>
> at java.lang.Thread.run(Thread.java:595)
>
>
> -------- 
>
> Priority : FATAL
>
> Class.Method(line):
> de.mrer.base.BaseComponent.validationFailedWithException(BaseComponent.java:
> 104)
>
> Message: de.mrer.exceptor.CustomException: [v.1.2B2 April 17 2006] Commit
> Exception
>
> ========================
>
> de.mrer.exceptor.CustomException: [v.1.2B2 April 17 2006] Commit Exception
>
> at
> de.mrer.base.CayenneBaseComponent.commitChanges(CayenneBaseComponent.java:74
> )
>
> at ImageEditPage.uploadFile(ImageEditPage.java:99)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> )
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> .java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
>
> at
> KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAccessor.
> java:54)
>
> at
> com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKe
> yValueCoding.java:1160)
>
> at
> com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey
> (NSKeyValueCoding.java:1268)
>
> at com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)
>
> at
> com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCod
> ing.java:498)
>
> at
> com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.va
> lueForKeyPath(NSKeyValueCodingAdditions.java:212)
>
> at
> com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1600)
>
> at
> com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOK
> eyValueAssociation.java:46)
>
> at
> com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton
> .java:59)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> tContent.java:31)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> tContent.java:31)
>
> at
> com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponen
> tContent.java:31)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at
> com.webobjects.appserver._private.WOConditional.invokeAction(WOConditional.j
> ava:55)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>
> at
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> entReference.java:104)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>
> at
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> entReference.java:104)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>
> at
> com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCompon
> entReference.java:104)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODyna
> micGroup.java:101)
>
> at
> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup
> .java:110)
>
> at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
>
> at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)
>
> at
> com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> paredPage(WOComponentRequestHandler.java:196)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> paredSession(WOComponentRequestHandler.java:287)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPre
> paredApplication(WOComponentRequestHandler.java:322)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(W
> OComponentRequestHandler.java:358)
>
> at
> com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WO
> ComponentRequestHandler.java:432)
>
> at
> com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:13
> 06)
>
> at
> com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java
> :173)
>
> at
> com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254
> )
>
> at java.lang.Thread.run(Thread.java:595)
>
> -------------------------------------------------
>
>
>   


Re: PK problem with Postgre

Posted by Andrus Adamchik <an...@objectstyle.org>.
I opened a Jira issue - will need to investigate. Any more clues,  
like does it happen under heavy load, or is it preceded by unrelated  
application errors that caused a transaction rollback?

http://issues.apache.org/cayenne/browse/CAY-526

Andrus


On Apr 22, 2006, at 1:37 PM, WONDER wrote:

> Hi Andrus,
> The explination from Jeff matches my observations. So answering your
> question is Yes. I saw that problem with 1.2B2 also.
>
> Sako
>
> ----- Original Message -----
> From: "Andrus Adamchik" <an...@objectstyle.org>
> To: <ca...@incubator.apache.org>
> Sent: Saturday, April 22, 2006 9:23 AM
> Subject: Re: PK problem with Postgre
>
>
>> Jeff,
>>
>> I am not sure if there was a race condition before, but since ~ M12-
>> B1 PK generator operates under slightly different conditions, being
>> tied to the commit transaction in progress. So have you seen this
>> problem recently?
>>
>> Andrus
>>
>>
>> On Apr 22, 2006, at 9:32 AM, Jeff de Vries wrote:
>>
>>> I have had this problem as well.  I'm using the "standard" value of
>>> 20 (meaning I haven't changed anything from the defaults), and I
>>> can see Cayenne query for the sequence value, followed by 20
>>> insertions using a value incremented by Cayenne, etc.
>>>
>>> When the problem happens, I've gone and looked at the sequence
>>> value in the database, and found, say, a value of 740, but there is
>>> already an existing record with a value of 740 as a primary key, so
>>> when Cayenne fetches the db sequence value of 740 and tries to use
>>> it, I get the "duplicate key" error below.
>>>
>>> At this point I haven't been able to pinpoint any particular set of
>>> events leading up to the problem (other than occasionally we crash
>>> [for other reasons] and perhaps that leaves something funky?).
>>>
>>> In my pre-Cayenne days I always left the primary key field
>>> unspecified and let PostgreSQL handle the incrementing.
>>>
>>> Jeff
>>>
>>>
>>> On Apr 20, 2006, at 6:43 AM, WONDER wrote:
>>>
>>>> Hi,
>>>>
>>>> I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501
>>>> JDBC 3
>>>> and Cayenne 1.2.B2.
>>>>
>>>> I use the Default Strategy to create the PKs using Cayenne. in the
>>>> DB, i
>>>> created the SEQ : pk_TableName. like pk_image for Table image.
>>>>
>>>> Sometimes I get the following error and sometimes it just work.
>>>> Till now, I coulding find the logic behind.
>>>>
>>>> Anybody can help?
>>>> Thanks.
>>>>
>>>> -------------------------------------------------
>>>> Priority : INFO
>>>>
>>>> Class.Method(line):
>>>> org.objectstyle.cayenne.access.QueryLogger.logQueryError
>>>> (QueryLogger.java:43
>>>> 9)
>>>>
>>>> Message: *** error.
>>>>
>>>> org.postgresql.util.PSQLException: ERROR: duplicate key violates
>>>> unique
>>>> constraint "image_pk"
>>>>
>>>
>>>
>>
>>
>
>


Re: does Cayenne creates objects by hisself?

Posted by Mike Kienenberger <mk...@gmail.com>.
setUser() or addToVisitorList() are standard cgen-created wrapper
methods which call setToOneTarget() or  addToManyTarget().   They
provide you with type-checking.   Also, in theory, if you ever had to
migrate away from Cayenne (undoubtably due to some political decision
rather than a technical one (-: ), it's easier to write code-generated
wrapper methods than to replace code that calls Cayenne classes
directly in your application classes.

    public void setDependentIndividual(SecIndividual dependentIndividual) {
        setToOneTarget("dependentIndividual",
(com.gvea.admindb.entity.cayenne.SecIndividual)dependentIndividual,
true);
    }

    public void addToParentRoleList(SecGroup obj) {
        addToManyTarget("parentRoleList",
(com.gvea.admindb.entity.cayenne.SecGroup)obj, true);
    }


On 4/22/06, WONDER <mm...@web.de> wrote:
> Ok. thx
>
> ps: why do you use setUser() or addToVisitorList() methods?
> Is it not better to use setToOneTarget() or  addToManyTarget()? I thought
> this will saves you to create the inverse relationship!
>
>
> peaSakoe
> ----- Original Message -----
> From: "Mike Kienenberger" <mk...@gmail.com>
> To: <ca...@incubator.apache.org>
> Sent: Saturday, April 22, 2006 1:57 PM
> Subject: Re: does Cayenne creates objects by hisself?
>
>
> No, you'd have to associate the visitor with a particular user
> somehow.   By default the relationship will be null.
>
> visitor.setUser(user)
>
> or
>
> user.addToVisitorList(visitor)
>
>
>
> On 4/22/06, WONDER <mm...@web.de> wrote:
> > Hi,
> >
> > I have the folloging situation.
> >
> > Entity "User"  has relation toMany "Visitor" its name is visitors.
> >
> > Usually if I "Fetch" the object Visitor from DB and then call
> >
> > visitor.user()
> >
> > Cayenne fetches the object User from the DB automatically.
> >
> >
> > Now, creating a Visitor object.
> >
> > Visitor visitor = new Visitor();
> >
> > and calling
> >
> > visitor.user()
> >
> > will Cayenne here creates the object User automatically, or I have to do
> it by myself?
> >
> > Thanks.
> >
>
>

Re: does Cayenne creates objects by hisself?

Posted by WONDER <mm...@web.de>.
Ok. thx

ps: why do you use setUser() or addToVisitorList() methods?
Is it not better to use setToOneTarget() or  addToManyTarget()? I thought
this will saves you to create the inverse relationship!


peaSakoe
----- Original Message ----- 
From: "Mike Kienenberger" <mk...@gmail.com>
To: <ca...@incubator.apache.org>
Sent: Saturday, April 22, 2006 1:57 PM
Subject: Re: does Cayenne creates objects by hisself?


No, you'd have to associate the visitor with a particular user
somehow.   By default the relationship will be null.

visitor.setUser(user)

or

user.addToVisitorList(visitor)



On 4/22/06, WONDER <mm...@web.de> wrote:
> Hi,
>
> I have the folloging situation.
>
> Entity "User"  has relation toMany "Visitor" its name is visitors.
>
> Usually if I "Fetch" the object Visitor from DB and then call
>
> visitor.user()
>
> Cayenne fetches the object User from the DB automatically.
>
>
> Now, creating a Visitor object.
>
> Visitor visitor = new Visitor();
>
> and calling
>
> visitor.user()
>
> will Cayenne here creates the object User automatically, or I have to do
it by myself?
>
> Thanks.
>


Re: does Cayenne creates objects by hisself?

Posted by Mike Kienenberger <mk...@gmail.com>.
No, you'd have to associate the visitor with a particular user
somehow.   By default the relationship will be null.

visitor.setUser(user)

or

user.addToVisitorList(visitor)



On 4/22/06, WONDER <mm...@web.de> wrote:
> Hi,
>
> I have the folloging situation.
>
> Entity "User"  has relation toMany "Visitor" its name is visitors.
>
> Usually if I "Fetch" the object Visitor from DB and then call
>
> visitor.user()
>
> Cayenne fetches the object User from the DB automatically.
>
>
> Now, creating a Visitor object.
>
> Visitor visitor = new Visitor();
>
> and calling
>
> visitor.user()
>
> will Cayenne here creates the object User automatically, or I have to do it by myself?
>
> Thanks.
>

does Cayenne creates objects by hisself?

Posted by WONDER <mm...@web.de>.
Hi,

I have the folloging situation.

Entity "User"  has relation toMany "Visitor" its name is visitors.

Usually if I "Fetch" the object Visitor from DB and then call 

visitor.user() 

Cayenne fetches the object User from the DB automatically.


Now, creating a Visitor object. 

Visitor visitor = new Visitor();

and calling 

visitor.user() 

will Cayenne here creates the object User automatically, or I have to do it by myself?

Thanks.

Re: PK problem with Postgre

Posted by WONDER <mm...@web.de>.
Hi Andrus,
The explination from Jeff matches my observations. So answering your
question is Yes. I saw that problem with 1.2B2 also.

Sako

----- Original Message ----- 
From: "Andrus Adamchik" <an...@objectstyle.org>
To: <ca...@incubator.apache.org>
Sent: Saturday, April 22, 2006 9:23 AM
Subject: Re: PK problem with Postgre


> Jeff,
>
> I am not sure if there was a race condition before, but since ~ M12-
> B1 PK generator operates under slightly different conditions, being
> tied to the commit transaction in progress. So have you seen this
> problem recently?
>
> Andrus
>
>
> On Apr 22, 2006, at 9:32 AM, Jeff de Vries wrote:
>
> > I have had this problem as well.  I'm using the "standard" value of
> > 20 (meaning I haven't changed anything from the defaults), and I
> > can see Cayenne query for the sequence value, followed by 20
> > insertions using a value incremented by Cayenne, etc.
> >
> > When the problem happens, I've gone and looked at the sequence
> > value in the database, and found, say, a value of 740, but there is
> > already an existing record with a value of 740 as a primary key, so
> > when Cayenne fetches the db sequence value of 740 and tries to use
> > it, I get the "duplicate key" error below.
> >
> > At this point I haven't been able to pinpoint any particular set of
> > events leading up to the problem (other than occasionally we crash
> > [for other reasons] and perhaps that leaves something funky?).
> >
> > In my pre-Cayenne days I always left the primary key field
> > unspecified and let PostgreSQL handle the incrementing.
> >
> > Jeff
> >
> >
> > On Apr 20, 2006, at 6:43 AM, WONDER wrote:
> >
> >> Hi,
> >>
> >> I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501
> >> JDBC 3
> >> and Cayenne 1.2.B2.
> >>
> >> I use the Default Strategy to create the PKs using Cayenne. in the
> >> DB, i
> >> created the SEQ : pk_TableName. like pk_image for Table image.
> >>
> >> Sometimes I get the following error and sometimes it just work.
> >> Till now, I coulding find the logic behind.
> >>
> >> Anybody can help?
> >> Thanks.
> >>
> >> -------------------------------------------------
> >> Priority : INFO
> >>
> >> Class.Method(line):
> >> org.objectstyle.cayenne.access.QueryLogger.logQueryError
> >> (QueryLogger.java:43
> >> 9)
> >>
> >> Message: *** error.
> >>
> >> org.postgresql.util.PSQLException: ERROR: duplicate key violates
> >> unique
> >> constraint "image_pk"
> >>
> >
> >
>
>


Re: PK problem with Postgre

Posted by Jeff de Vries <jd...@pfrog.com>.
We haven't upgraded to M12-B1 yet.  We'll do that and see what happens.

This has only happened maybe 3-4 times, under very light load  
(basically a single user doing web interaction testing, though each  
interaction would hit maybe 5-6 interrelated tables).

Naturally, it occurred once during a demo to upper management!  :-(

Jeff

On Apr 22, 2006, at 12:23 AM, Andrus Adamchik wrote:

> Jeff,
>
> I am not sure if there was a race condition before, but since ~ M12- 
> B1 PK generator operates under slightly different conditions, being  
> tied to the commit transaction in progress. So have you seen this  
> problem recently?
>
> Andrus
>
>
> On Apr 22, 2006, at 9:32 AM, Jeff de Vries wrote:
>
>> I have had this problem as well.  I'm using the "standard" value  
>> of 20 (meaning I haven't changed anything from the defaults), and  
>> I can see Cayenne query for the sequence value, followed by 20  
>> insertions using a value incremented by Cayenne, etc.
>>
>> When the problem happens, I've gone and looked at the sequence  
>> value in the database, and found, say, a value of 740, but there  
>> is already an existing record with a value of 740 as a primary  
>> key, so when Cayenne fetches the db sequence value of 740 and  
>> tries to use it, I get the "duplicate key" error below.
>>
>> At this point I haven't been able to pinpoint any particular set  
>> of events leading up to the problem (other than occasionally we  
>> crash [for other reasons] and perhaps that leaves something funky?).
>>
>> In my pre-Cayenne days I always left the primary key field  
>> unspecified and let PostgreSQL handle the incrementing.
>>
>> Jeff
>>
>>
>> On Apr 20, 2006, at 6:43 AM, WONDER wrote:
>>
>>> Hi,
>>>
>>> I have problem with PostGreSQL ver 8.1.3 using JDBC ver  
>>> 8.2dev-501 JDBC 3
>>> and Cayenne 1.2.B2.
>>>
>>> I use the Default Strategy to create the PKs using Cayenne. in  
>>> the DB, i
>>> created the SEQ : pk_TableName. like pk_image for Table image.
>>>
>>> Sometimes I get the following error and sometimes it just work.
>>> Till now, I coulding find the logic behind.
>>>
>>> Anybody can help?
>>> Thanks.
>>>
>>> -------------------------------------------------
>>> Priority : INFO
>>>
>>> Class.Method(line):
>>> org.objectstyle.cayenne.access.QueryLogger.logQueryError 
>>> (QueryLogger.java:43
>>> 9)
>>>
>>> Message: *** error.
>>>
>>> org.postgresql.util.PSQLException: ERROR: duplicate key violates  
>>> unique
>>> constraint "image_pk"
>>>
>>
>>
>


Re: PK problem with Postgre

Posted by Andrus Adamchik <an...@objectstyle.org>.
Jeff,

I am not sure if there was a race condition before, but since ~ M12- 
B1 PK generator operates under slightly different conditions, being  
tied to the commit transaction in progress. So have you seen this  
problem recently?

Andrus


On Apr 22, 2006, at 9:32 AM, Jeff de Vries wrote:

> I have had this problem as well.  I'm using the "standard" value of  
> 20 (meaning I haven't changed anything from the defaults), and I  
> can see Cayenne query for the sequence value, followed by 20  
> insertions using a value incremented by Cayenne, etc.
>
> When the problem happens, I've gone and looked at the sequence  
> value in the database, and found, say, a value of 740, but there is  
> already an existing record with a value of 740 as a primary key, so  
> when Cayenne fetches the db sequence value of 740 and tries to use  
> it, I get the "duplicate key" error below.
>
> At this point I haven't been able to pinpoint any particular set of  
> events leading up to the problem (other than occasionally we crash  
> [for other reasons] and perhaps that leaves something funky?).
>
> In my pre-Cayenne days I always left the primary key field  
> unspecified and let PostgreSQL handle the incrementing.
>
> Jeff
>
>
> On Apr 20, 2006, at 6:43 AM, WONDER wrote:
>
>> Hi,
>>
>> I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501  
>> JDBC 3
>> and Cayenne 1.2.B2.
>>
>> I use the Default Strategy to create the PKs using Cayenne. in the  
>> DB, i
>> created the SEQ : pk_TableName. like pk_image for Table image.
>>
>> Sometimes I get the following error and sometimes it just work.
>> Till now, I coulding find the logic behind.
>>
>> Anybody can help?
>> Thanks.
>>
>> -------------------------------------------------
>> Priority : INFO
>>
>> Class.Method(line):
>> org.objectstyle.cayenne.access.QueryLogger.logQueryError 
>> (QueryLogger.java:43
>> 9)
>>
>> Message: *** error.
>>
>> org.postgresql.util.PSQLException: ERROR: duplicate key violates  
>> unique
>> constraint "image_pk"
>>
>
>


Re: PK problem with Postgre

Posted by Jeff de Vries <jd...@pfrog.com>.
I have had this problem as well.  I'm using the "standard" value of  
20 (meaning I haven't changed anything from the defaults), and I can  
see Cayenne query for the sequence value, followed by 20 insertions  
using a value incremented by Cayenne, etc.

When the problem happens, I've gone and looked at the sequence value  
in the database, and found, say, a value of 740, but there is already  
an existing record with a value of 740 as a primary key, so when  
Cayenne fetches the db sequence value of 740 and tries to use it, I  
get the "duplicate key" error below.

At this point I haven't been able to pinpoint any particular set of  
events leading up to the problem (other than occasionally we crash  
[for other reasons] and perhaps that leaves something funky?).

In my pre-Cayenne days I always left the primary key field  
unspecified and let PostgreSQL handle the incrementing.

Jeff


On Apr 20, 2006, at 6:43 AM, WONDER wrote:

> Hi,
>
> I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501  
> JDBC 3
> and Cayenne 1.2.B2.
>
> I use the Default Strategy to create the PKs using Cayenne. in the  
> DB, i
> created the SEQ : pk_TableName. like pk_image for Table image.
>
> Sometimes I get the following error and sometimes it just work.
> Till now, I coulding find the logic behind.
>
> Anybody can help?
> Thanks.
>
> -------------------------------------------------
> Priority : INFO
>
> Class.Method(line):
> org.objectstyle.cayenne.access.QueryLogger.logQueryError 
> (QueryLogger.java:43
> 9)
>
> Message: *** error.
>
> org.postgresql.util.PSQLException: ERROR: duplicate key violates  
> unique
> constraint "image_pk"
>


Re: PK problem with Postgre

Posted by WONDER <mm...@web.de>.
My table has no higher PKs.
Its Cayenne or PostGre which does not use the seq correctly. so once it
increments the seq and another not.
Dont ask me why, otherwise I would be able to solve the problem :)

thx.
----- Original Message ----- 
From: "Bryan Lewis" <br...@maine.rr.com>
To: <ca...@incubator.apache.org>
Sent: Thursday, April 20, 2006 4:30 PM
Subject: Re: PK problem with Postgre


> Here's my guess.  Your image table had some existing data before you
> added the sequence for Cayenne's use.  When the modeler adds a sequence,
> it defaults to a starting value of 200, with SQL like this:
>
>     CREATE SEQUENCE pk_image START WITH 200 INCREMENT BY 20;
>
> If your table already had primary keys with values of 200 and above,
> you'll get an occasional error like the one you saw. You can check this
> by looking at the log just before the error; you'll see what primary key
> the SQL is trying to assign.
>
> The fix would be to adjust the start value for the sequence to be higher
> than any value in the table.
>
>
> WONDER wrote:
>
> >Hi,
> >
> >I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501 JDBC 3
> >and Cayenne 1.2.B2.
> >
> >I use the Default Strategy to create the PKs using Cayenne. in the DB, i
> >created the SEQ : pk_TableName. like pk_image for Table image.
> >
> >Sometimes I get the following error and sometimes it just work.
> >Till now, I coulding find the logic behind.
> >
> >Anybody can help?
> >Thanks.
> >
> >-------------------------------------------------
> >Priority : INFO
> >
> >Class.Method(line):
>
>org.objectstyle.cayenne.access.QueryLogger.logQueryError(QueryLogger.java:4
3
> >9)
> >
> >Message: *** error.
> >
> >org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
> >constraint "image_pk"
> >
> >at
>
>org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutor
I
> >mpl.java:1513)
> >
> >at
> >
> >
>
>


Re: PK problem with Postgre

Posted by Mike Kienenberger <mk...@gmail.com>.
Well, that could be the problem.   You need to make sure that the
cayenne model and the database are using the same value -- there's no
"magic" that allows cayenne to figure this out.

The default strategy is probably to use 20.

If you're using sequences, my suggestion would be to explicitly say so
in your model so you can control the increment interval.

On 4/20/06, WONDER <mm...@web.de> wrote:
> I changed the "INCREMENT BY 1" into "INCREMENT BY 3" in PostGreSQL.
> The cayenne still increments by 1.
> I think the default PK strategy does not use the seq correctly.
>
>
>
>
> > ----- Original Message -----
> > From: "Mike Kienenberger" <mk...@gmail.com>
> > To: <ca...@incubator.apache.org>
> > Sent: Thursday, April 20, 2006 4:32 PM
> > Subject: Re: PK problem with Postgre
> >
> >
> > On 4/20/06, Bryan Lewis <br...@maine.rr.com> wrote:
> > > Here's my guess.  Your image table had some existing data before you
> > > added the sequence for Cayenne's use.  When the modeler adds a sequence,
> > > it defaults to a starting value of 200, with SQL like this:
> > >
> > >     CREATE SEQUENCE pk_image START WITH 200 INCREMENT BY 20;
> >
> > Another thing to keep in mind is that EOF defaults to "INCREMENT BY 1"
> > while Cayenne defaults to "INCREMENT BY 20".   Not sure if it'll have
> > any bearing on your situation.
> >
> >
>
>

Re: PK problem with Postgre

Posted by WONDER <mm...@web.de>.
I changed the "INCREMENT BY 1" into "INCREMENT BY 3" in PostGreSQL.
The cayenne still increments by 1.
I think the default PK strategy does not use the seq correctly.




> ----- Original Message ----- 
> From: "Mike Kienenberger" <mk...@gmail.com>
> To: <ca...@incubator.apache.org>
> Sent: Thursday, April 20, 2006 4:32 PM
> Subject: Re: PK problem with Postgre
>
>
> On 4/20/06, Bryan Lewis <br...@maine.rr.com> wrote:
> > Here's my guess.  Your image table had some existing data before you
> > added the sequence for Cayenne's use.  When the modeler adds a sequence,
> > it defaults to a starting value of 200, with SQL like this:
> >
> >     CREATE SEQUENCE pk_image START WITH 200 INCREMENT BY 20;
>
> Another thing to keep in mind is that EOF defaults to "INCREMENT BY 1"
> while Cayenne defaults to "INCREMENT BY 20".   Not sure if it'll have
> any bearing on your situation.
>
>


Re: PK problem with Postgre

Posted by WONDER <mm...@web.de>.
In general does not make any diffrence. This is interresting if I have more
than one application insert in the same table.
however, I dont think this makes problems.

thx

----- Original Message ----- 
From: "Mike Kienenberger" <mk...@gmail.com>
To: <ca...@incubator.apache.org>
Sent: Thursday, April 20, 2006 4:32 PM
Subject: Re: PK problem with Postgre


On 4/20/06, Bryan Lewis <br...@maine.rr.com> wrote:
> Here's my guess.  Your image table had some existing data before you
> added the sequence for Cayenne's use.  When the modeler adds a sequence,
> it defaults to a starting value of 200, with SQL like this:
>
>     CREATE SEQUENCE pk_image START WITH 200 INCREMENT BY 20;

Another thing to keep in mind is that EOF defaults to "INCREMENT BY 1"
while Cayenne defaults to "INCREMENT BY 20".   Not sure if it'll have
any bearing on your situation.


Re: PK problem with Postgre

Posted by Mike Kienenberger <mk...@gmail.com>.
On 4/20/06, Bryan Lewis <br...@maine.rr.com> wrote:
> Here's my guess.  Your image table had some existing data before you
> added the sequence for Cayenne's use.  When the modeler adds a sequence,
> it defaults to a starting value of 200, with SQL like this:
>
>     CREATE SEQUENCE pk_image START WITH 200 INCREMENT BY 20;

Another thing to keep in mind is that EOF defaults to "INCREMENT BY 1"
while Cayenne defaults to "INCREMENT BY 20".   Not sure if it'll have
any bearing on your situation.

Re: PK problem with Postgre

Posted by Bryan Lewis <br...@maine.rr.com>.
Here's my guess.  Your image table had some existing data before you
added the sequence for Cayenne's use.  When the modeler adds a sequence,
it defaults to a starting value of 200, with SQL like this:

    CREATE SEQUENCE pk_image START WITH 200 INCREMENT BY 20;

If your table already had primary keys with values of 200 and above,
you'll get an occasional error like the one you saw. You can check this
by looking at the log just before the error; you'll see what primary key
the SQL is trying to assign.

The fix would be to adjust the start value for the sequence to be higher
than any value in the table.


WONDER wrote:

>Hi,
>
>I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501 JDBC 3
>and Cayenne 1.2.B2.
>
>I use the Default Strategy to create the PKs using Cayenne. in the DB, i
>created the SEQ : pk_TableName. like pk_image for Table image.
>
>Sometimes I get the following error and sometimes it just work.
>Till now, I coulding find the logic behind.
>
>Anybody can help?
>Thanks.
>
>-------------------------------------------------
>Priority : INFO
>
>Class.Method(line):
>org.objectstyle.cayenne.access.QueryLogger.logQueryError(QueryLogger.java:43
>9)
>
>Message: *** error.
>
>org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
>constraint "image_pk"
>
>at
>org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorI
>mpl.java:1513)
>
>at
>  
>