castor
  1. castor
  2. CASTOR-1239

Database.getIdentity(Object) should be able to resolve identity without relying on the object having been loaded from the database

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.9
    • Fix Version/s: 0.9.9.1
    • Component/s: JDO
    • Labels:
      None
    • Number of attachments :
      2

      Description

      Currently, Database.getIdentity() returns null if the object has not been loaded in the same transaction.

      Consider the following scenario:

      • An object has been loaded from the database in a previous transaction
      • The object hs been marshaled to XML and sent to a client app
      • the client marks the object for removal and sends it back
      • The server unmarshalls the object in a new transaction- this gives a new instance
      • since remove() is also restricted to within transactions, i need to reload the original.
      • the obvious way to do that is with the newly received object's identity
      1. patch-C1239-20051108.txt
        8 kB
        Ralf Joachim
      2. patch-C1239-20051110.txt
        9 kB
        Ralf Joachim

        Activity

        Hide
        Ralf Joachim added a comment -

        Refactor org.exolab.castor.jdo.Utils to org.castor.jdo.util.JDOUtils and declare Utils as deprecated.
        Add static closeDatabase() utility method.
        Add static getIdentity() utility method.

        The same code can be used to allow Database.getIdentity() to also return identity of objects that are not in the current transaction as this will be the more frequently usecase.

        Show
        Ralf Joachim added a comment - Refactor org.exolab.castor.jdo.Utils to org.castor.jdo.util.JDOUtils and declare Utils as deprecated. Add static closeDatabase() utility method. Add static getIdentity() utility method. The same code can be used to allow Database.getIdentity() to also return identity of objects that are not in the current transaction as this will be the more frequently usecase.
        Hide
        Werner Guttmann added a comment -

        Let's go ahead and commit this code. Maybe you could find some time to make the comments in closeDatabase() a bit more readable ? Somehow this seems to have been copied from somewhere ..

        Show
        Werner Guttmann added a comment - Let's go ahead and commit this code. Maybe you could find some time to make the comments in closeDatabase() a bit more readable ? Somehow this seems to have been copied from somewhere ..
        Hide
        Ralf Joachim added a comment -

        Final patch which improves Database.getIdentity() instead of adding JDOUtils.getIdentity() helper method. The other changes contained in the previous patch have been resolved with CASTOR-1259 and CASTOR-1260.

        Show
        Ralf Joachim added a comment - Final patch which improves Database.getIdentity() instead of adding JDOUtils.getIdentity() helper method. The other changes contained in the previous patch have been resolved with CASTOR-1259 and CASTOR-1260 .

          People

          • Assignee:
            Ralf Joachim
            Reporter:
            Henk van Voorthujsen
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: