• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

jdo persistence question  RSS feed

 
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
 
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 ]
 
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!