Re: PK problem with Postgre

From: Lindsay Steele (lsteel..inet.net.au)
Date: Thu Apr 20 2006 - 17:11:00 EDT

  • Next message: Bryan Lewis: "Re: PK problem with Postgre"

    This is interesting - I had tried this in the past and had problems ...
    as you can see in this thread.

    http://www.objectstyle.org/cayenne/lists/cayenne-user/2006/01/0055.html

    http://www.objectstyle.org/cayenne/lists/cayenne-user/2006/01/0058.html

    I have just tried it again and my quick testing seems to indicate that
    it will now work with a cached PK size that is not directly related
    to the postgres "increment by" value. I am guessing something has
    changed in the latest releases maybe ?

    Not to sure if I should change to 20 now for performance or leave it at
    1 because I know that works.

    Gentry, Michael (Contractor) wrote:
    > I had a Cayenne/PostgreSQL test/example application and used the default
    > PK size of 20 and it worked OK for me. I haven't tried to run it in a
    > few months, though, but I know that used to function correctly.
    >
    >
    > -----Original Message-----
    > From: Lindsay Steele [mailto:lsteel..inet.net.au]
    > Sent: Thursday, April 20, 2006 4:44 PM
    > To: cayenne-use..ncubator.apache.org
    > Subject: Re: PK problem with Postgre
    >
    >
    > 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.jav
    > a:43
    >
    >> 9)
    >>
    >> Message: *** error.
    >>
    >> org.postgresql.util.PSQLException: ERROR: duplicate key violates
    >>
    > unique
    >
    >> constraint "image_pk"
    >>
    >> at
    >>
    >>
    > org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecu
    > torI
    >
    >> mpl.java:1513)
    >>
    >> at
    >>
    >>
    > org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImp
    > l.ja
    >
    >> va:1298)
    >>
    >> at
    >>
    >>
    > org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:
    > 349)
    >
    >> at
    >>
    >>
    > org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2St
    > atem
    >
    >> ent.java:2559)
    >>
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.jdbc.BatchAction.runAsBatch(BatchAction.j
    > ava:
    >
    >> 164)
    >>
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.jdbc.BatchAction.performAction(BatchActio
    > n.ja
    >
    >> va:114)
    >>
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQuer
    > yAct
    >
    >> ion.java:95)
    >>
    >> at
    >>
    > org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:309
    > )
    >
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.DataDomainFlushAction.runQueries(DataDoma
    > inFl
    >
    >> ushAction.java:255)
    >>
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.DataDomainFlushAction.flush(DataDomainFlu
    > shAc
    >
    >> tion.java:177)
    >>
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:82
    > 7)
    >
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.DataDomain$2.transform(DataDomain.java:79
    > 8)
    >
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.DataDomain.runInTransaction(DataDomain.ja
    > va:8
    >
    >> 53)
    >>
    >> at
    >>
    > org.objectstyle.cayenne.access.DataDomain.onSync(DataDomain.java:795)
    >
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.DataContext.flushToParent(DataContext.jav
    > a:12
    >
    >> 17)
    >>
    >> at
    >>
    >>
    > org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.jav
    > a:11
    >
    >> 21)
    >>
    >> at
    >>
    >>
    > de.mrer.base.CayenneBaseComponent.commitChanges(CayenneBaseComponent.jav
    > a:65
    >
    >> )
    >>
    >> at ImageEditPage.uploadFile(ImageEditPage.java:99)
    >>
    >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    >>
    >> at
    >>
    >>
    > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
    > a:39
    >
    >> )
    >>
    >> at
    >>
    >>
    > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
    > Impl
    >
    >> .java:25)
    >>
    >> at java.lang.reflect.Method.invoke(Method.java:585)
    >>
    >> at
    >>
    >>
    > KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAcces
    > sor.
    >
    >> java:54)
    >>
    >> at
    >>
    >>
    > com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(
    > NSKe
    >
    >> yValueCoding.java:1160)
    >>
    >> at
    >>
    >>
    > com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueFo
    > rKey
    >
    >> (NSKeyValueCoding.java:1268)
    >>
    >> at
    >>
    > com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)
    >
    >> at
    >>
    >>
    > com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValu
    > eCod
    >
    >> ing.java:498)
    >>
    >> at
    >>
    >>
    > com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementatio
    > n.va
    >
    >> lueForKeyPath(NSKeyValueCodingAdditions.java:212)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:16
    > 00)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent
    > (WOK
    >
    >> eyValueAssociation.java:46)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitBu
    > tton
    >
    >> .java:59)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComp
    > onen
    >
    >> tContent.java:31)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComp
    > onen
    >
    >> tContent.java:31)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComp
    > onen
    >
    >> tContent.java:31)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOConditional.invokeAction(WOCondition
    > al.j
    >
    >> ava:55)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    > com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCo
    > mpon
    >
    >> entReference.java:104)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    > com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    > com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCo
    > mpon
    >
    >> entReference.java:104)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    > com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCo
    > mpon
    >
    >> entReference.java:104)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .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:1
    > 375)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWit
    > hPre
    >
    >> paredPage(WOComponentRequestHandler.java:196)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWit
    > hPre
    >
    >> paredSession(WOComponentRequestHandler.java:287)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWit
    > hPre
    >
    >> paredApplication(WOComponentRequestHandler.java:322)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler._handleReque
    > st(W
    >
    >> OComponentRequestHandler.java:358)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler.handleReques
    > t(WO
    >
    >> ComponentRequestHandler.java:432)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.jav
    > a: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.j
    > ava:
    >
    >> 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.jav
    > a:74
    >
    >> )
    >>
    >> at ImageEditPage.uploadFile(ImageEditPage.java:99)
    >>
    >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    >>
    >> at
    >>
    >>
    > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
    > a:39
    >
    >> )
    >>
    >> at
    >>
    >>
    > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
    > Impl
    >
    >> .java:25)
    >>
    >> at java.lang.reflect.Method.invoke(Method.java:585)
    >>
    >> at
    >>
    >>
    > KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAcces
    > sor.
    >
    >> java:54)
    >>
    >> at
    >>
    >>
    > com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(
    > NSKe
    >
    >> yValueCoding.java:1160)
    >>
    >> at
    >>
    >>
    > com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueFo
    > rKey
    >
    >> (NSKeyValueCoding.java:1268)
    >>
    >> at
    >>
    > com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)
    >
    >> at
    >>
    >>
    > com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValu
    > eCod
    >
    >> ing.java:498)
    >>
    >> at
    >>
    >>
    > com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementatio
    > n.va
    >
    >> lueForKeyPath(NSKeyValueCodingAdditions.java:212)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:16
    > 00)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent
    > (WOK
    >
    >> eyValueAssociation.java:46)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitBu
    > tton
    >
    >> .java:59)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComp
    > onen
    >
    >> tContent.java:31)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComp
    > onen
    >
    >> tContent.java:31)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComp
    > onen
    >
    >> tContent.java:31)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOConditional.invokeAction(WOCondition
    > al.j
    >
    >> ava:55)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    > com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCo
    > mpon
    >
    >> entReference.java:104)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    > com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    > com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCo
    > mpon
    >
    >> entReference.java:104)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .java:110)
    >>
    >> at
    >>
    > com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentReference.invokeAction(WOCo
    > mpon
    >
    >> entReference.java:104)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
    > Dyna
    >
    >> micGroup.java:101)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
    > roup
    >
    >> .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:1
    > 375)
    >
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWit
    > hPre
    >
    >> paredPage(WOComponentRequestHandler.java:196)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWit
    > hPre
    >
    >> paredSession(WOComponentRequestHandler.java:287)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWit
    > hPre
    >
    >> paredApplication(WOComponentRequestHandler.java:322)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler._handleReque
    > st(W
    >
    >> OComponentRequestHandler.java:358)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver._private.WOComponentRequestHandler.handleReques
    > t(WO
    >
    >> ComponentRequestHandler.java:432)
    >>
    >> at
    >>
    >>
    > com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.jav
    > a: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)
    >>
    >> -------------------------------------------------
    >>
    >>
    >>
    >>
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Thu Apr 20 2006 - 17:11:35 EDT