kazu2012 / persevere-framework

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

new object IDs? #54

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When I create a new object at the command line, I can immediately see its id as 
expected:

var c = new MyClass();
c.id // prints out "MyClass/12"

but when I try to do this from within one of my class methods, I don't get the 
same printout.  When 
I try to print it out with console.log( "new id: " + c.id ); I get the 
following output

INFO: new id: s$133

whereas I would expect to see MyClass/12 (or whatever the appropriate ID number 
is).

Original issue reported on code.google.com by lst...@gmail.com on 25 Dec 2008 at 11:38

GoogleCodeExporter commented 8 years ago
Just FYI, this is because every evaluation at the console runs as a full 
transaction
(auto-committing after each evaluation) unless you set autocommit to false. In a
class method, each request is a transaction, so the whole function is executed 
in a
single transaction, which does not commit until finished. Currently, the id for 
a new
object is not assigned to an object until the transaction is committed, because 
the
data to be persisted is not sent to the database until committal, so when the
transaction is still open and uncomitted, the id is a temporary id.

That being said, this is still an issue, and I would like to fix this (by 
querying
the database for a new id prior to committing the transaction).

Original comment by nikki...@gmail.com on 26 Dec 2008 at 5:46

GoogleCodeExporter commented 8 years ago
OK, thanks - in the meantime I can do an extra commit to get the ID associated 
with the new object.

Original comment by lst...@gmail.com on 27 Dec 2008 at 6:50

GoogleCodeExporter commented 8 years ago

Original comment by kris...@gmail.com on 30 Apr 2009 at 3:38

GoogleCodeExporter commented 8 years ago

Original comment by kris...@gmail.com on 6 Jun 2009 at 4:09