I'm having a problem with objects fetched from the database. All JDOs are treated as Transient objects when they have just been fetched from the database. Thus, they don't have object ids (.jdoGetObjectId() returns null) or a reference to a PM (.jdoGetPersistenceManager() returns null). obj.jdoIsPersistent() and JDOHelper.isPersistent(obj) both return false (obviously, since they're the same). As a result, when I setX() on the objects, the PM does not propagate the changes back to the database even though the object was just loaded from the database. I have one test JSP like this (slightly condensed):
Iterator iterator = pm.getExtent(User.class, false).iterator(); while (iterator.hasNext()) { User user = (User) iterator.next(); boolean b = JDOHelper.isPersistent(user)); // .... }
b is almost always false. Only when user is a newly or recently created object will it be in the Persistent state. I can fetch it using Extents or Queries and isPersistent() returns true in that case. At some point, however, recently inserted objects stop being retrieved as persistent objects and become like the others. I have not been able to discern a cause; they seem to "expire" after a few minutes. Restarting Tomcat will definitely cause retrieved objects to be treated as transient. I am using "application" type persistence, but from what I could gather from the documentation, that is supported without any special programmer support.
I have seen several mentions in the list archives for this list of similar problems, but no resolution. Given that the JDO implementation would be practically useless without being able to update persistent JDOs, I am certain that this is user error, but after spending a whole day trying to track this down, I am out of ideas. I would greatly appreciate a pointer in the right direction.
More details:
As far as configuration goes, I am using default OBJ.properties settings. I have verified my repository_user.xml and *.jdo files. I am not using any of the internal tables because I am not using any of the features for which it is required.
Software packages I am using:
DB-OJB 1.0 RC3 (could not build RC4)
Tomcat 4.1.something (WinXP) JDK 1.4.2 (WinXP) J2EE 1.3.1 (WinXP) PostgreSQL 7.3.3 (on FreeBSD)
Things I have tried:
Defining my own object id class
Using a single, static instance of PersistenceManager instead of going to PersistenceManagerFactory multiple times
Fiddling with the location of the queries in the transaction
Obtaining JDOs via Extents vs. Queries
forcing cache reloads with evict() and refresh()
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]