JDO: Is the PersistenceManager single?

Just the basics: I am using DataNucleus, supported by the built-in DB4O database.

If I do this simple test:

    PersistenceManager pm1 = persistenceManagerFactory.getPersistenceManager();
    PersistenceManager pm2 = persistenceManagerFactory.getPersistenceManager();

    pm1.makePersistent(t1);
    pm2.makePersistent(t2);

I get a file lock exception:

com.db4o.ext.DatabaseFileLockedException: C:\<path>\primary_datastore.data

Which tells me that I don’t know how it should work PersistenceManager. I thought I just called PersistenceManagerFactorywhenever I needed PersistenceManagerto query or save data, and I would get something thread safe.

  • Does PersistenceManager need to do a singleton through my entire expression?
  • How to make multiple threads, query execution and updates work in JDO / DataNucleus?
+3
source share
4 answers

PersistenceManager ?

. , , , . persistence-manager . . , - . PersistenceManager. , PersistenceManager . PersistenceManager .

, PersistenceManager / .

+2

, , :

PersistenceManager pm1 = persistenceManagerFactory.getPersistenceManager();
PersistenceManager pm2 = persistenceManagerFactory.getPersistenceManagerProxy();

pm1.makePersistent(t1);
pm2.makePersistent(t2);

- , PersistenceManager.

, :

Properties properties = new Properties();
properties.setProperty("javax.jdo.PersistenceManagerFactoryClass",
                "org.datanucleus.jdo.JDOPersistenceManagerFactory");
//configure connection, etc...
properties.setProperty("javax.jdo.option.Multithreaded", "true");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(properties);
+2

, DB4O NeoDatis ( DN , 5- ), , , . , , , (, ) 4 , .

, DB4O ( , ), NeoDatis " ". , , JDO DataNucleus.

I can’t imagine how to return to DB4O after three days of hell that were erased with 5 minutes of NeoDatis bliss. :)

+2
source

How exactly do you expect db4o to support concurrent requests when operating in file mode? Assume server mode is a prerequisite

+1
source

Source: https://habr.com/ru/post/1771873/


All Articles