Is it possible to Autowire
the JDO PersistenceManager
?
In the example below, only the PersistenceManagerFactory
is Autowired
, while the PersistenceManager
is obtained using a getter and utility method before each operation.
import org.springframework.orm.jdo.PersistenceManagerFactoryUtils;
@Service
public class MainServiceImpl implements MainService
{
@Autowired
private PersistenceManagerFactory pmf;
private PersistenceManager pm;
public void setPersistenceManager(PersistenceManager pm)
{
this.pm = pm;
}
public void setPmf(PersistenceManagerFactory pmf)
{
this.pmf = pmf;
}
public PersistenceManagerFactory getPmf()
{
return pmf;
}
public PersistenceManager getPersistenceManager()
{
return PersistenceManagerFactoryUtils.getPersistenceManager(pmf, true);
}
}