Announcement Announcement Module
Collapse
No announcement yet.
JdoTemplate.execute(..) Loses Queried Objects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JdoTemplate.execute(..) Loses Queried Objects

    I just changed my DAO code to use JdoTemplate. Finding objects this way results in no objects being returned. The old way, I do get them. When I looked in the debugger, I can see that there was an object found in the database, but it seems to be cleaned up and disappears in this method of JdoTemplate:

    execute(JdoCallback action, boolean exposeNativePersistenceManager)

    ... and on this line of code in that method (in the finally clause):

    PersistenceManagerFactoryUtils.releasePersistenceM anager(pm, getPersistenceManagerFactory());

    I don't know why this would happen, but obviously something I don't know about persistence manager related stuff. I'm using JPOX with Spring, pretty much like I saw on JPOX website and in the "Java Development with the Spring Framework" book.

    If you have the answer, I'd appreciate it! Oh, I'm using Spring 1.2.5 (maybe should upgrade), and JPOX 1.1.0-beta-6. I'm running within Websphere Studio with Websphere app server.

    Update: I tried turning nonTransactionalRead to false (JPOX), and in that case I end up with a TransactionNotActiveException in that same execute method. It tells me that I either need to turn that setting back to true, or define a transaction around this. I thought that Spring was going to handle the transactions.

    Another update: Found a bunch of other posts about this, and I'm not clear on what the solution is for using getJdoTemplate().find(....) for reads. Any advice?

    Thanks,

    Larry
    Last edited by con19m31; Feb 17th, 2006, 12:05 AM. Reason: New Information

  • #2
    The only version of Spring that I know of that has full support for the Apache JDO 2.0-beta jar (and JPOX 1.1.0-beta-6) is 2.0-M2 (signatures of makePersistent() methods were changed). Maybe someone from the Spring team can comment if those changes to JDO2 support made it into the 1.2.* series ?
    You can probably ask the question on the dev mailing list to get a fast answer. 1.2.7 version has a lot of bugfixes ported from the 2.0 but I'm not sure about the features since 2.0 will be/is 100% compatible with 1.2.x.

    Comment


    • #3
      I did define transactions using Spring. I followed same pattern as pet clinic sample on JPOX website. I'm confused about this now though, because if we need to do the detach inside a transaction, and assuming JdoTemplate doesn't do that, then I don't understand how we can use a find method with JdoTemplate (unless it does the detach).

      I read several other threads asking the same question I asked, and I didn't take anything definitive away from having read those threads.

      Seems to me that JdoTemplate is currently of use for makePersistent calls only, until such time as Spring builds in a detach capability inside of transactions. Anyone agree/disagree with that?

      Larry

      Comment


      • #4
        My mistake here - Andy said it above, that you need M2 Spring with JPOX 1.1.0-beta-6.......

        Thanks.

        Comment

        Working...
        X