kazu2012 / persevere-framework

Automatically exported from code.google.com/p/persevere-framework
0 stars 0 forks source link

Removed but still Referenced Objects Causing Pain #183

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If I assign an object to another, and I remove the referred to object, I
can't get to the original any more.

Like this:

Make parent object:
  js>t = new Toot()
  [object Object]

Make child object
  js>t_ = new Toot()
  [object Object]

Make relationship
  js>t.other = t_
  [object Object]

Check : s( ) == serialize( )
  js>s( t )
  ({"id":"Toot/8",
    "name":"Toot-Thu May 21 2009 16:55:20 GMT-0700 (PDT)",
    "accesses":0,
    "prop":0,
    "other":{"$ref":"Toot/9"}
   })

OK.  Now remove. The referee.  Bad form, I know, but it's going to happen.
  js>remove( t_ )
  true

Object's still happy.  In fact now I could set t.other to undefined just fine.
  js>s( t )
  ({"id":"Toot/8",
    "name":"Toot-Thu May 21 2009 16:55:20 GMT-0700 (PDT)",
    "accesses":0,
    "prop":0,
    "other":{"$ref":"Toot/9"}
  })

But, instead I'm going to go away...
  js>shutdown
  c:\master>persvr
  2009-05-21 16:56:21.448::INFO:  Logging to STDERR via org.mortbay. ...
  2009-05-21 16:56:21.555::INFO:  jetty-6.1.14
  INFO: Persevere v1.0 beta 2 Started
  2009-05-21 ...INFO:  Started   SelectChannelConnector@0.0.0.0:8080
  Type "help" at the console for more information

OK. Back again.  Now.  How 'bout that object?

  js>t=load( "Toot/8" )
  [object Object]

Let's look at it:
  js>s( t )
  InternalError: Toot/9 not found
          at util.js:1

Let's try to get rid of that old reference:  Ouch, can't.

  js>t.object = undefined
org.persvr.data.ObjectNotFoundException: InternalError: Toot/9 not found
        at
org.persvr.datasource.JavaScriptDBSource.mapObject(JavaScriptDBSource.java:127)
        at
org.persvr.data.PersistableObject.mapPersistent(PersistableObject.java:668)
        at org.persvr.data.ObjectId.resolveTarget(ObjectId.java:145)
        at org.persvr.data.ObjectId.resolveTarget(ObjectId.java:1)
        at org.persvr.data.Identification.getTarget(Identification.java:157)
        at org.persvr.data.PersistableObject.get(PersistableObject.java:145)
        at
org.persvr.data.PersistableObject$EntrySet$1.getNextValue(PersistableObject.java
:841)
        at
org.persvr.data.PersistableObject$EntrySet$1.next(PersistableObject.java:851)
        at
org.persvr.data.PersistableObject$EntrySet$1.next(PersistableObject.java:1)
        at
org.persvr.datasource.JavaScriptDB.writeObject(JavaScriptDB.java:969)
        at
org.persvr.datasource.JavaScriptDB.writeEntity(JavaScriptDB.java:1143)
        at
org.persvr.datasource.JavaScriptDB.writeObject(JavaScriptDB.java:918)
        at
org.persvr.datasource.JavaScriptDB.writeObject(JavaScriptDB.java:985)
        at
org.persvr.datasource.JavaScriptDB.writeEntity(JavaScriptDB.java:1143)
        at
org.persvr.datasource.JavaScriptDB.commitTransaction(JavaScriptDB.java:2534)
        at
org.persvr.datasource.JavaScriptDBSource.commitTransaction(JavaScriptDBSource.ja
va:99)
        at org.persvr.data.Transaction.commit(Transaction.java:225)
        at org.persvr.util.Console.evaluate(Console.java:129)
        at org.persvr.util.Console$1.run(Console.java:108)
        at
org.persvr.security.UserSecurity.doPriviledgedAction(UserSecurity.java:59)
        at org.persvr.util.Console.run(Console.java:49)

Original issue reported on code.google.com by davidthi...@gmail.com on 22 May 2009 at 1:13

GoogleCodeExporter commented 8 years ago
yeah, I also ran across this using david's handy delete-all-objects forEach 
loop, but
my comment over on bug #124 was really crappy (i was only thinking of it in that
context).  
Voting to move this up the priority list...

Original comment by dty...@gmail.com on 22 May 2009 at 1:25

GoogleCodeExporter commented 8 years ago
I checked in a fix that will make property references to non-existent objects 
return a 
null. I think that perhaps a more idealistic solution would be to track down 
all 
references to an object, but this will require an index in the database to 
track 
references (which adds some overhead), and won't work for cross-source 
references, so 
will this fix be sufficient for now?

Original comment by kris...@gmail.com on 22 May 2009 at 3:22

GoogleCodeExporter commented 8 years ago

Original comment by kris...@gmail.com on 22 May 2009 at 3:22

GoogleCodeExporter commented 8 years ago
that works for me - Dylan

Original comment by dty...@gmail.com on 22 May 2009 at 3:24

GoogleCodeExporter commented 8 years ago
Fixed the main issue, marking this as low priority now for remaining work.

Original comment by kris...@gmail.com on 27 May 2009 at 3:47

GoogleCodeExporter commented 8 years ago

Original comment by davidthi...@gmail.com on 31 May 2009 at 2:15