6 Replies Latest reply on Jun 13, 2008 11:11 AM by jason.greene

    Persistence

    swtet

      I am using the file cache loader to persist my POJOs to disk for testing. I am doing something like this:

      obj = cache.find( fqn );
      if( obj == null ) {
      obj = new X();
      cache.attach( fqn, obj );
      }

      obj.setBlah( "blah" );

      I do see my X object written out to disk but if I kill my process and restart it, all of the fields of X are back to defaults. So, I would expect something like:

      obj.getBlah();

      to return "blah" but it returns null. Am I missing a step? Should any updates I make to "obj" be persisted as well?

      A somewhat unrelated question....if I persist to a DB, does it serialize the whole object when an update is made or does it just persist the fields that are changed like during replication? It would appear the file cache loader writes the whole object every time (well, not for me right now) which could be fairly inefficient.

      Thanks
      Tony

        • 1. Re: Persistence
          manik

          Are you actually instrumenting your objects, either at compile time or runtime, as per the POJO Cache user guide?

          Cache loaders will persist whatever is in the cache - and a properly instrumented object will exist in the cache as a set of primitive values. So if you are seeing the entire object being serialized AND your updates aren't being picked up, I suspect you haven't instrumented your classes properly.

          • 2. Re: Persistence
            swtet

            Well, I thought I had them instrumented. I am trying use runtime instrumentation. Is there any way to debug things to see if it is picking up the javaagent and finding the annotated class when it loads?

            • 3. Re: Persistence
              manik

              Set your log4j config to enable TRACE level logging for org.jboss.cache and org.jboss.aop classes and you should see it.

              • 4. Re: Persistence
                jason.greene

                What version are you using?

                • 5. Re: Persistence
                  swtet

                  I resolved my issue. Besides the -javaagent, I had to make sure I specified the location of the pojocache-aop.xml file. I ultimately wanted that file to be in my classpath so I had to set "jboss.aop.search.classpath=true" and change the name of the xml file to jboss-aop.xml. I tracked this down by looking at the source code. Is that method of configuration documented somewhere (I couldn't find it) or do you plan to drop support for it in the future?

                  Thanks

                  • 6. Re: Persistence
                    jason.greene

                    There are no plans to drop this feature. This reminds me, I have been meaning to enhance aop to allow for loading an aop descriptor of a different name under the classpath.