Commit problem

8 posts, 0 answers
  1. Joao Castro
    Joao Castro avatar
    4 posts
    Member since:
    Mar 2010

    Posted 02 Mar 2010 Link to this post

    I'm still using  open access 4.3.0.378  and sometimes commit fails and the record I'm inserting in Database is inserted.

            try {
                    Performs pf3 = Performs.AddNew(scope,  ... );

                    scope.Transaction.Commit();
                }
                catch (Exception exc)
                {
                    try { scope.Transaction.Rollback(); }
                    catch { };
                  }

     (Exception of type 'OpenAccess.OpenAccessException' was thrown.
    at com.versant.core.jdo.VersantPersistenceManagerImp.handleException(Exception x)
       at com.versant.core.jdo.VersantPersistenceManagerImp.internalCommit(Boolean phase)
       at com.versant.core.jdo.VersantPersistenceManagerImp.commit()
       at com.versant.core.jdo.SynchronizedPMProxy.commit()
       at OpenAccess.RT.TransactionImpl.Commit() )


    How can I know if the commits fails or succeds ?

    Thanks in advanced
    Joao Castro

  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 03 Mar 2010 Link to this post

    Hello Joao Castro,
    If the object is inserted the commit should not fail. Can you send me more information about the exception? The message as well as the InnerExceptions?

    Kind regards,
    Jan Blessenohl
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Joao Castro
    Joao Castro avatar
    4 posts
    Member since:
    Mar 2010

    Posted 16 Mar 2010 Link to this post

    Hi, I still have the same problem ... Can u help me getting inner exceptions ?
    My Log File don't have inner exception information ...




    catch (Exception exc)
                {
                    try { scope.Transaction.Rollback(); }
                    catch { };
                                    
                    ErrorForm.Show(...);

                    LogClass.WriteError("MSG: " + exc.Message + "\nST: " + exc.StackTrace +
                        "\nIE: " + exc.InnerException.ToString() + "\nLOG: " +  strLog.ToString());
                }

    Thanks.

    Joao Castro


  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 17 Mar 2010 Link to this post

    Hello Joao Castro,
    Your code looks good. In your first post even the exception message was not visible. What are you getting now?

    Best wishes,
    Jan Blessenohl
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Joao Castro
    Joao Castro avatar
    4 posts
    Member since:
    Mar 2010

    Posted 17 Mar 2010 Link to this post

    The InnerException doesn't have any information. What can I do ?

    16-03-2010 16:54:23
      :MSG: Exception of type 'OpenAccess.OpenAccessException' was thrown.
    ST:    at com.versant.core.jdo.VersantPersistenceManagerImp.handleException(Exception x)
       at com.versant.core.jdo.VersantPersistenceManagerImp.internalCommit(Boolean phase)
       at com.versant.core.jdo.VersantPersistenceManagerImp.commit()
       at com.versant.core.jdo.SynchronizedPMProxy.commit()
       at OpenAccess.RT.TransactionImpl.Commit()
       at OPT.Gesvia.Forms.VehicleRostering.DailyRoster.DailyRosterForm.AddPerforms(ShiftsStretches shst, Vehicle v)
    IE:
    LOG: ---OPT.Gesvia.Forms.VehicleRostering.DailyRoster.DailyRosterForm.AddPerforms---

    Thanks
    Joao Castro
  7. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 17 Mar 2010 Link to this post

    Hello Joao Castro,
    Hm, maybe ToString() is not working, if the InnerException is null you should get a null reference exception. I am also wondering why the message is so cryptical, can you add exc.ToString() and exc.InnerException.Message & .StackTrace?

    Kind regards,
    Jan Blessenohl
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Joao Castro
    Joao Castro avatar
    4 posts
    Member since:
    Mar 2010

    Posted 17 Mar 2010 Link to this post

    Sorry, My post was not so clear ...

    MyLogFile has:

    exc.Message = Exception of type 'OpenAccess.OpenAccessException' was thrown.

    exc.StackTrace = at com.versant.core.jdo.VersantPersistenceManagerImp.handleException(Exception x)
       at com.versant.core.jdo.VersantPersistenceManagerImp.internalCommit(Boolean phase)
       at com.versant.core.jdo.VersantPersistenceManagerImp.commit()
       at com.versant.core.jdo.SynchronizedPMProxy.commit()
       at OpenAccess.RT.TransactionImpl.Commit()
       at OPT.Gesvia.Forms.VehicleRostering.DailyRoster.DailyRosterForm.AddPerforms(ShiftsStretches shst, Vehicle v)

    exc.InnerException.ToString() = ""

    My catch code is

    ---------------------------------------------------------
    catch (Exception exc)
                {
                    //jvc:set09 - no transaction
                    try { scope.Transaction.Rollback(); }
                    catch { };
                                    
                    ErrorForm.Show();

                    string strOpenAccessDetails = "";
                    try{ strOpenAccessDetails = exc.InnerException.ToString(); }
                    catch { };

                    LogClass.WriteError("MSG: " + exc.Message + "\nST: " + exc.StackTrace +
                        "\nIE: " + strOpenAccessDetails );
                }

    How can I get the InnerExceptions ?

    Please Help
    Thanks
    Joao Castro




  9. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 19 Mar 2010 Link to this post

    Hello Joao Castro,
    I am doing the following:

    class Program
    {
        static void Main(string[] args)
        {
            IObjectScope scope = Database.Get("DatabaseConnection1").GetObjectScope();
            scope.Transaction.Begin();
            scope.Add(new Person() { Id = 1, Name = "name1" });
            try
            {
                scope.Transaction.Commit();
            }
            catch (Exception e)
            {
                Console.WriteLine("Msg: \r\n" + e.Message + "\r\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                Console.WriteLine("ToString: \r\n" + e + "\r\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                Console.WriteLine("StackTrace: \r\n" + e.StackTrace + "\r\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            }
            scope.Dispose();
        }
    }
    [Persistent(IdentityField="id")]
    class Person
    {
        private int id;
        public int Id
        {
            get { return id; }
            set { id = value; }
        }
        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }

    If you run it twice the result is:

    Msg:
    Insert of '284046613-1' failed: Telerik.OpenAccess.RT.sql.SQLException: Violatio
    n of PRIMARY KEY constraint 'pk_person'. Cannot insert duplicate key in object '
    dbo.person'.
    The statement has been terminated.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewO
    bjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldN
    os, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
    INSERT INTO [person] ([id], [nme], [voa_version]) VALUES (?, ?, ?)
    (set event logging to all to see parameter values)
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ToString:
    Telerik.OpenAccess.Exceptions.DuplicateKeyException: Insert of '284046613-1' fai
    led: Telerik.OpenAccess.RT.sql.SQLException: Violation of PRIMARY KEY constraint
     'pk_person'. Cannot insert duplicate key in object 'dbo.person'.
    The statement has been terminated.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewO
    bjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldN
    os, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
    INSERT INTO [person] ([id], [nme], [voa_version]) VALUES (?, ?, ?)
    (set event logging to all to see parameter values) ---> Telerik.OpenAccess.RT.sq
    l.SQLException: Violation of PRIMARY KEY constraint 'pk_person'. Cannot insert d
    uplicate key in object 'dbo.person'.
    The statement has been terminated.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewO
    bjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldN
    os, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
       --- End of inner exception stack trace ---
       at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
       at Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleExcept
    ion(Exception x)
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.internalComm
    it(Boolean phase)
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
       at OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.commit()
       at Telerik.OpenAccess.RT.TransactionImpl.Commit()
       at ErrorHandling.Program.Main(String[] args) in C:\Users\blessenohl\Documents
    \Visual Studio 2008\Projects\ErrorHandling\ErrorHandling\Program.cs:line 19
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    StackTrace:
       at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
       at Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleExcept
    ion(Exception x)
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.internalComm
    it(Boolean phase)
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
       at OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.commit()
       at Telerik.OpenAccess.RT.TransactionImpl.Commit()
       at ErrorHandling.Program.Main(String[] args) in C:\Users\blessenohl\Documents
    \Visual Studio 2008\Projects\ErrorHandling\ErrorHandling\Program.cs:line 19
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Press any key to continue . . .

    As you can see the exception title has the type of exception plus the text describing what happens. In your case I cannot see that. If you use e.ToString() the stacktrace plus the inner exception is printed. What happens if you run my code?

    My problem with your log file content i that i cannot see the real cause of the exception, it is not in the title nor in the inner exception and that cannot be.

    Best wishes,
    Jan Blessenohl
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
DevCraft banner