Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6561023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:32:12+00:00 2026-05-25T13:32:12+00:00

I am using Datanucleus, JDO and Spring’s declarative @Transactional management woven with Aspect-J. But

  • 0

I am using Datanucleus, JDO and Spring’s declarative @Transactional management woven with Aspect-J.

But when a ‘normal’ method gets a persistent object from a @Transactional method, the object’s state will become transient (the persistence manager seems to be removed) and the object is no longer persistent.

Example:

public class Example {

    public void test() throws Exception {
       Login l = getLogin();                          
       JDOHelper.getObjectState(l);              // transient instead of persistent
       l.getSomeOtherPersistentObj().doStuff();  // NullpointerException :(
    }

    @Transactional
    private Login getLogin() {
        // do transactional stuff here
        // ..
        return dao.find(Login.class, 1);
    }
}

Why is this and how can I fix it without adding @Transactional in places where transactions are not needed? The following does (obviously) work so this indicates that a transactional as well as a non-transactional connection can be made:

  • A @Transactional method calls a @Transactional method
  • A @Transactional method calls a normal method
  • A normal method calls a normal method

If I call dao.refresh(l), I get: ‘Object with id “” is managed by a different Object Manager’, so maybe Spring is working on a different persistence manager than the DAO, is this the cause?

Here’s my spring configuration (it might be relevant):

<bean id="pmf" class="org.datanucleus.api.jdo.JDOPersistenceManagerFactory" destroy-method="close">
  <property name="connectionDriverName" value="com.mysql.jdbc.Driver"/>
  ...
  <constructor-arg>
    <map>
      <entry key="datanucleus.autoCreateSchema" value="true" />
    </map>
  </constructor-arg>
</bean>
<bean id="myPmfProxy" class="org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy">
  <property name="targetPersistenceManagerFactory" ref="pmf" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jdo.JdoTransactionManager">
  <property name="persistenceManagerFactory" ref="myPmfProxy" /> 
</bean>
<bean id="JDODao" class="sw.JDODao">
  <property name="persistenceManagerFactory" ref="myPmfProxy" /> 
</bean>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:32:12+00:00Added an answer on May 25, 2026 at 1:32 pm

    It turned out that my objects need to be detachable to do this.

    Iv’e added (detachable="true") to my @PersistenceCapable annotations and set the following datanucleus options:

    <entry key="datanucleus.DetachAllOnCommit" value="true" />
    <entry key="datanucleus.detachedState" value="all" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using DataNucleus' implement of JDO on a local H2 database. I want
I am using Datanucleus JDO on top of HSqlDb. I would like to execute
I am using Guice with JDO and Datanucleus in my desktop app. I am
I am using DataNucleus's implementation of JDO on an H2 database instance opened in
I am using DataNucleus' implementation of JDO to populate a table on a local
Assuming one has an operational Java application using DataNucleus's implementation of JDO to access
I use ANT to run my JDO application example implemented using Datanucleus solution. When
I am trying to run grails on google app engine using JDO, but I
I am trying to follow the DataNucleus tutorial for JDO. I am using Maven
I'm creating an MVC Spring webapp. Using: Jetty (servlet container), DataNucleus (dao platform), DB4O

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.