Re: COMMIT or ROLLBACK TRANSACTION statement is missing.

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Sep 21 2005 - 14:53:05 EDT

  • Next message: Andrus Adamchik: "Re: Registering extended types"

    Good that you found a workaround. Though the original setup should
    work too ... as long as there is an ObjAttribute mapped for each
    key... This is how your object property is propagated to PK in
    PrimaryKeyHelper:

    ObjAttribute objAttr = objEntity.getAttributeForDbAttribute(dbAttr);
    if (objAttr != null) {
         idMap.put(dbAttrName, object.readPropertyDirectly(objAttr.getName
    ()));
         continue;
    }

    So, doublecheck that you have disciplineID and userID mapped on the
    object side and you call appropriate setters before commit.

    Andrus

    On Sep 20, 2005, at 7:04 AM, Filip Balas wrote:

    > Okay, for completeness... for anyone else who may
    > encounter this problem, just :
    >
    > create an identity column
    > set the identity column as the PK in the DB and Modeler
    > set the other two columns as a combined indices in DB
    > (if you need them to be unique as I did)
    >
    > Problem goes away.
    >
    > Filip
    >
    >
    > On 9/20/05, Filip Balas <fbala..mail.com> wrote:
    >
    >
    >> After further investigation it appears that
    >> the problem has to do with my combined key.
    >>
    >> I have a table with two fields.
    >> disciplineID
    >> userID
    >> Both are user input and form a combined key.
    >>
    >> I have these fields set as a combined key
    >> in the database. I have the 'PK' boxes selected
    >> in the Cayenne modeler and the 'Generated' unchecked.
    >>
    >> Now when I try to create a new object using Cayenne,
    >> An exception is thrown at line 194 of PrimaryKeyHelper.java
    >> (using cayenne 1.2M3). I am not familiar with the code
    >> but it appears as though Cayenne has tried to generate a PK
    >> itself, and then tried to get the database to generate a PK
    >> and failed in all cases. My problem is it should not be trying
    >> to generate anything at all... once the two required fields are set,
    >> the combination IS the PK. I have checked and both fields are set.
    >>
    >> Am I doing something wrong?
    >>
    >> Filip
    >>
    >>
    >>
    >>
    >> On 9/19/05, Filip Balas <fbala..mail.com> wrote:
    >>
    >>
    >>> The following statements:
    >>> DisciplineLead_RelationshipConnected aDL_Connected =
    >>> (DisciplineLead_RelationshipConnected)
    >>> getDataContext().createAndRegisterNewObject
    >>> (DisciplineLead_RelationshipConnected.class);
    >>>
    >>> aDL_Connected.setDiscipline(aDL_context, getDiscipline());
    >>> aDL_Connected.setUser(aDL_context, getUser());
    >>> getDataContext().commitChanges() ;
    >>>
    >>> Produce the following cayenne exception:
    >>> Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK
    >>> TRANSACTION statement is missing. Previous count = 0, current
    >>> count =
    >>> 1.
    >>>
    >>> I do not perform any commits prior to executing this.
    >>> How is this possible?
    >>>
    >>> Filip
    >>>
    >>>
    >>>
    >>
    >>
    >>
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Sep 21 2005 - 14:53:11 EDT