當前位置: 首頁>>代碼示例>>Java>>正文


Java PersistenceManagerFactory.getPersistenceManager方法代碼示例

本文整理匯總了Java中javax.jdo.PersistenceManagerFactory.getPersistenceManager方法的典型用法代碼示例。如果您正苦於以下問題:Java PersistenceManagerFactory.getPersistenceManager方法的具體用法?Java PersistenceManagerFactory.getPersistenceManager怎麽用?Java PersistenceManagerFactory.getPersistenceManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jdo.PersistenceManagerFactory的用法示例。


在下文中一共展示了PersistenceManagerFactory.getPersistenceManager方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
public void init(int doublesPerRow) {
	System.out.println("Storing to database");
	ZooHelper.getDataStoreManager().createDb(dbName);
	
	ZooJdoProperties prop = new ZooJdoProperties(dbName);
	PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(prop);
	pmf.setRetainValues(false);
	pm = pmf.getPersistenceManager();
	pm.currentTransaction().begin();
	
	list = new PersistentArrayDoubleParent(doublesPerRow);
	pm.makePersistent(list);
	
	pad = list.getNextForWrite2();
	data = pad.getData();
}
 
開發者ID:tzaeschke,項目名稱:TinSpin,代碼行數:17,代碼來源:DbWriter.java

示例2: getPersistManager

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
private PersistenceManager getPersistManager(MetadbConf metadbConf) {
  //TODO: get params from dbConf
  String driver = metadbConf.getJdbcDriverName();

  LOG.info("Connecting to Metastore with driver: " + driver);

  Properties properties = new Properties();
  properties.setProperty("javax.jdo.option.ConnectionURL",
          "jdbc:derby:metastore_db;create=true");

  properties.setProperty("javax.jdo.option.ConnectionDriverName",
          driver);

  properties.setProperty("javax.jdo.option.ConnectionUserName", "");
  properties.setProperty("javax.jdo.option.ConnectionPassword", "");
  properties.setProperty("datanucleus.schema.autoCreateSchema", "true");
  properties.setProperty("datanucleus.schema.autoCreateTables", "true");
  properties.setProperty("datanucleus.schema.validateTables", "false");
  properties.setProperty("datanucleus.schema.validateConstraints", "false");

  PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(properties);
  PersistenceManager pm = pmf.getPersistenceManager();

  return  pm;
}
 
開發者ID:andyhehk,項目名稱:SecureDB,代碼行數:26,代碼來源:ConnectionPool.java

示例3: getPersistenceManager

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
public  Object getPersistenceManager(String client,PersistenceManagerFactory pmf) 
{
	Map<String,PersistenceManager> map = (Map<String,PersistenceManager>)super.get();
	PersistenceManager pm = null;
	if (map != null)
		pm = map.get(client);
	
    if(pm == null || pm.isClosed()) 
    {
        pm = pmf.getPersistenceManager( ); 
        pm.setUserObject(client);
        if (map == null)
        	map = new HashMap<>();
        map.put(client, pm);
        set(map);
    }

    return pm;
}
 
開發者ID:SeldonIO,項目名稱:seldon-server,代碼行數:20,代碼來源:JDOPMRetriever.java

示例4: doGetPersistenceManager

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
/**
 * Obtain a JDO PersistenceManager via the given factory. Is aware of a
 * corresponding PersistenceManager bound to the current thread,
 * for example when using JdoTransactionManager. Will create a new
 * PersistenceManager else, if "allowCreate" is {@code true}.
 * <p>Same as {@code getPersistenceManager}, but throwing the original JDOException.
 * @param pmf PersistenceManagerFactory to create the PersistenceManager with
 * @param allowCreate if a non-transactional PersistenceManager should be created
 * when no transactional PersistenceManager can be found for the current thread
 * @return the PersistenceManager
 * @throws JDOException if the PersistenceManager couldn't be created
 * @throws IllegalStateException if no thread-bound PersistenceManager found and
 * "allowCreate" is {@code false}
 * @see #getPersistenceManager(javax.jdo.PersistenceManagerFactory, boolean)
 * @see JdoTransactionManager
 */
public static PersistenceManager doGetPersistenceManager(PersistenceManagerFactory pmf, boolean allowCreate)
	throws JDOException, IllegalStateException {

	Assert.notNull(pmf, "No PersistenceManagerFactory specified");

	PersistenceManagerHolder pmHolder =
			(PersistenceManagerHolder) TransactionSynchronizationManager.getResource(pmf);
	if (pmHolder != null) {
		if (!pmHolder.isSynchronizedWithTransaction() &&
				TransactionSynchronizationManager.isSynchronizationActive()) {
			pmHolder.setSynchronizedWithTransaction(true);
			TransactionSynchronizationManager.registerSynchronization(
					new PersistenceManagerSynchronization(pmHolder, pmf, false));
		}
		return pmHolder.getPersistenceManager();
	}

	if (!allowCreate && !TransactionSynchronizationManager.isSynchronizationActive()) {
		throw new IllegalStateException("No JDO PersistenceManager bound to thread, " +
				"and configuration does not allow creation of non-transactional one here");
	}

	logger.debug("Opening JDO PersistenceManager");
	PersistenceManager pm = pmf.getPersistenceManager();

	if (TransactionSynchronizationManager.isSynchronizationActive()) {
		logger.debug("Registering transaction synchronization for JDO PersistenceManager");
		// Use same PersistenceManager for further JDO actions within the transaction.
		// Thread object will get removed by synchronization at transaction completion.
		pmHolder = new PersistenceManagerHolder(pm);
		pmHolder.setSynchronizedWithTransaction(true);
		TransactionSynchronizationManager.registerSynchronization(
				new PersistenceManagerSynchronization(pmHolder, pmf, true));
		TransactionSynchronizationManager.bindResource(pmf, pmHolder);
	}

	return pm;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:55,代碼來源:PersistenceManagerFactoryUtils.java

示例5: main

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
public static void main(String[] args) {
	PersistenceManagerFactory persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory("Tutorial");
	PersistenceManager persistenceManager = persistenceManagerFactory.getPersistenceManager();
	
	List<Item> executeList = persistenceManager.newQuery(Item.class).filter("").executeList();
	System.out.println(executeList);
	Item pc = persistenceManager.newInstance(Item.class);
	//pc.related.add(executeList.get(0));
	//pc.id=1;
	Product ps=new Product();
	pc.product=ps;
	pc.url="DD";
	persistenceManager.makePersistent(pc);
	//persistenceManager.currentTransaction().commit();		
}
 
開發者ID:OnPositive,項目名稱:aml,代碼行數:16,代碼來源:T.java

示例6: getTransactionalPersistenceManager

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
protected PersistenceManager getTransactionalPersistenceManager(final File localRoot) {
	final PersistenceManagerFactory pmf;
	try (final LocalRepoManager localRepoManagerLocal = localRepoManagerFactory.createLocalRepoManagerForExistingRepository(localRoot);)
	{
		try (final LocalRepoTransaction transaction = localRepoManagerLocal.beginWriteTransaction();)
		{
			pmf = ((LocalRepoTransactionImpl)transaction).getPersistenceManager().getPersistenceManagerFactory();
		}
	}
	final PersistenceManager pm = pmf.getPersistenceManager();
	pm.currentTransaction().begin();
	return pm;
}
 
開發者ID:subshare,項目名稱:subshare,代碼行數:14,代碼來源:AbstractRepoToRepoSyncIT.java

示例7: printAll

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
private static void printAll(PersistenceManagerFactory pmf, Class clazz) {
    PersistenceManager pm = pmf.getPersistenceManager();
    Query q = pm.newQuery(clazz);
    for (Object o : (List) q.execute()) {
        System.out.println(o);
    }
}
 
開發者ID:subhrajitroy,項目名稱:osgi-jdo-sample,代碼行數:8,代碼來源:EntityServiceImpl.java

示例8: readFromDB_Array

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
private double[] readFromDB_Array(String dbName, TestStats ts) {
	log("Reading from database");
	
	ZooJdoProperties prop = new ZooJdoProperties(dbName);
	PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(prop);
	//pmf.setRetainValues(false);
	PersistenceManager pm = pmf.getPersistenceManager();
	pm.currentTransaction().begin();
	
	Extent<PersistentArrayDoubleParent> ext = pm.getExtent(PersistentArrayDoubleParent.class);
	PersistentArrayDoubleParent pa = ext.iterator().next();
	ext.closeAll();
	
	int maxEntries;
	if (pa.getEntryCount() < ts.cfgNEntries) {
		maxEntries = pa.getEntryCount();
		ts.cfgNEntries = maxEntries;
	} else {
		maxEntries = ts.cfgNEntries;
	}
	
	double[] ret = new double[maxEntries*2*DIM];
	int pos = 0;
	for (PersistentArrayDouble d: pa.getData()) {
		double[] da = d.getData();
		if (pos+da.length <= ret.length) {
			System.arraycopy(da, 0, ret, pos, da.length);
		} else {
			//special case for last 'da' if we do not read all data
			if (ret.length-pos > 0) {
				System.arraycopy(da, 0, ret, pos, ret.length-pos);
			}
			break;
		}
		pos += da.length;
	}
	
	pm.currentTransaction().commit();
	pm.close();
	pmf.close();
	
	return ret;
}
 
開發者ID:tzaeschke,項目名稱:TinSpin,代碼行數:44,代碼來源:OsmRect2D.java

示例9: readFromDB_Array

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
private double[] readFromDB_Array(String dbName, TestStats ts) {
	log("Reading from database");
	
	ZooJdoProperties prop = new ZooJdoProperties(dbName);
	PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(prop);
	//pmf.setRetainValues(false);
	PersistenceManager pm = pmf.getPersistenceManager();
	pm.currentTransaction().begin();
	
	Extent<PersistentArrayDoubleParent> ext = pm.getExtent(PersistentArrayDoubleParent.class);
	PersistentArrayDoubleParent pa = ext.iterator().next();
	ext.closeAll();
	
	int maxEntries;
	if (pa.getEntryCount() < ts.cfgNEntries) {
		maxEntries = pa.getEntryCount();
		ts.cfgNEntries = maxEntries;
	} else {
		maxEntries = ts.cfgNEntries;
	}
	
	double[] ret = new double[maxEntries*2];
	int pos = 0;
	for (PersistentArrayDouble d: pa.getData()) {
		double[] da = d.getData();
		if (pos+da.length <= ret.length) {
			System.arraycopy(da, 0, ret, pos, da.length);
		} else {
			//special case for last 'da' if we do not read all data
			if (ret.length-pos > 0) {
				System.arraycopy(da, 0, ret, pos, ret.length-pos);
			}
			break;
		}
		pos += da.length;
	}
	
	pm.currentTransaction().commit();
	pm.close();
	pmf.close();
	
	return ret;
}
 
開發者ID:tzaeschke,項目名稱:TinSpin,代碼行數:44,代碼來源:OsmPoint2D.java

示例10: readFromDB_Array

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
private static double[] readFromDB_Array(String dbName, TestStats ts) {
	log("Reading from database");
	
	ZooJdoProperties prop = new ZooJdoProperties(dbName);
	PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(prop);
	pmf.setRetainValues(false);
	PersistenceManager pm = pmf.getPersistenceManager();
	pm.currentTransaction().begin();
	
	Extent<PersistentArrayDoubleParent> ext = pm.getExtent(PersistentArrayDoubleParent.class);
	PersistentArrayDoubleParent pa = ext.iterator().next();
	ext.closeAll();
	
	int maxEntries;
	if (pa.getEntryCount() < ts.cfgNEntries) {
		maxEntries = pa.getEntryCount();
		ts.cfgNEntries = maxEntries;
	} else {
		maxEntries = ts.cfgNEntries;
	}
	
	double[] ret = new double[maxEntries*2];
	int pos = 0;
	for (PersistentArrayDouble d: pa.getData()) {
		double[] da = d.getData();
		if (pos+da.length <= ret.length) {
			System.arraycopy(da, 0, ret, pos, da.length);
		} else {
			//special case for last 'da' if we do not read all data
			if (ret.length-pos > 0) {
				System.arraycopy(da, 0, ret, pos, ret.length-pos);
			}
			break;
		}
		pos += da.length;
	}
	
	pm.currentTransaction().commit();
	pm.close();
	pmf.close();
	
	return ret;
}
 
開發者ID:tzaeschke,項目名稱:TinSpin,代碼行數:44,代碼來源:TigerKmlPoint2D.java

示例11: readFromDB_Array

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
private static double[] readFromDB_Array(String dbName, TestStats ts) {
	log("Reading from database");
	
	ZooJdoProperties prop = new ZooJdoProperties(dbName);
	PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(prop);
	pmf.setRetainValues(false);
	PersistenceManager pm = pmf.getPersistenceManager();
	pm.currentTransaction().begin();
	
	Extent<PersistentArrayDoubleParent> ext = pm.getExtent(PersistentArrayDoubleParent.class);
	PersistentArrayDoubleParent pa = ext.iterator().next();
	ext.closeAll();
	
	int maxEntries;
	if (pa.getEntryCount() < ts.cfgNEntries) {
		maxEntries = pa.getEntryCount();
		ts.cfgNEntries = maxEntries;
	} else {
		maxEntries = ts.cfgNEntries;
	}
	
	double[] ret = new double[maxEntries*2*ts.cfgNDims];
	int pos = 0;
	for (PersistentArrayDouble d: pa.getData()) {
		double[] da = d.getData();
		if (pos+da.length <= ret.length) {
			System.arraycopy(da, 0, ret, pos, da.length);
		} else {
			//special case for last 'da' if we do not read all data
			if (ret.length-pos > 0) {
				System.arraycopy(da, 0, ret, pos, ret.length-pos);
			}
			break;
		}
		pos += da.length;
	}
	
	pm.currentTransaction().commit();
	pm.close();
	pmf.close();
	
	return ret;
}
 
開發者ID:tzaeschke,項目名稱:TinSpin,代碼行數:44,代碼來源:TigerKmlRect2D.java

示例12: createPersistanceManager

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
protected PersistanceManager createPersistanceManager(){
	PersistenceManagerFactory persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory("Tutorial");
	return new JDOPersistanceManager( persistenceManagerFactory.getPersistenceManager());
}
 
開發者ID:OnPositive,項目名稱:aml,代碼行數:5,代碼來源:ResourceWithPersitanceManager.java

示例13: createPersistenceManager

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
public PersistenceManager createPersistenceManager() {
  final PersistenceManagerFactory emf = getPersistenceManagerFactory();
  return emf.getPersistenceManager();
}
 
開發者ID:highsource,項目名稱:hyperjaxb3,代碼行數:5,代碼來源:AbstractJDOTest.java

示例14: getPersistenceManager

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
public PersistenceManager getPersistenceManager() {
  final PersistenceManagerFactory emf = getPersistenceManagerFactory();
  return emf.getPersistenceManager();
}
 
開發者ID:highsource,項目名稱:hyperjaxb3,代碼行數:5,代碼來源:JDOTest.java

示例15: getPersistenceManager

import javax.jdo.PersistenceManagerFactory; //導入方法依賴的package包/類
@Provides @RequestScoped @Inject
PersistenceManager getPersistenceManager(PersistenceManagerFactory pmf) {
  return pmf.getPersistenceManager();
}
 
開發者ID:rodion-goritskov,項目名稱:test-analytics-ng,代碼行數:5,代碼來源:GuiceProviderModule.java


注:本文中的javax.jdo.PersistenceManagerFactory.getPersistenceManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。