• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdo persistence question

 
Kieth Nogins
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi;
I want to extract an object from a DB and then be able to use it throughout the application after I close the DB_transaction.
I use objectDB(I dont know if that matters).

What I tried to do was:
1)open a transaction
2)extract the object from the DB (I put it in a variable "var")
3)close the transaction (commit())

Then when I tried to modify var in another place I got:
javax.jdo.JDOUserException: Object cannot be modified without transaction

please help
 
Erik Bengtson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The state of the "var" is not clear to me. If you want to apply changes to "var" and update the database later, you must detach the "var", and if you don't need to update the database, you can just make the "var" transient.

After pm.close, however, the "var" should transition to transient state, and this you can raise to the ObjectDB team if it does not work

[ May 26, 2006: Message edited by: Erik Bengtson ]
[ May 26, 2006: Message edited by: Erik Bengtson ]
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My advice to you is not to do this. detached objects are not what they seem. Create another object that is a proxy of sorts for your database object. Let that proxy hold your database object. When you want to modify your db object use the proxy.

For each modification the proxy should open a transaction, modify the db object, then close the transaction.

Again, steer clear of attach/detach, its not what it seems.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic