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


Java JDOHelper.getPersistenceManagerFactory方法代碼示例

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


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

示例1: init

import javax.jdo.JDOHelper; //導入方法依賴的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: start

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@Override
public void start(Properties conf, UpdateLoggerFactory updateLoggerFactory)
        throws MetaException {
    Properties props = new Properties();
    props.setProperty("javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
    props.setProperty("datanucleus.ConnectionDriverName", conf.getProperty("metastore.jdo.connection.drivername"));
    props.setProperty("datanucleus.ConnectionURL", conf.getProperty("metastore.jdo.connection.URL"));
    props.setProperty("datanucleus.ConnectionUserName", conf.getProperty("metastore.jdo.connection.username"));
    props.setProperty("datanucleus.ConnectionPassword", conf.getProperty("metastore.jdo.connection.password"));
    props.setProperty("datanucleus.connectionPoolingType", "DBCP");
    props.setProperty("datanucleus.schema.autoCreateAll", "true");

    if (conf.getProperty("metastore.jdo.connection.drivername").equals("org.sqlite.JDBC")) {
        // for sequences
        props.setProperty("datanucleus.valuegeneration.transactionAttribute", "UsePM");
        // connection pooling occurs NullPointerException
        props.setProperty("datanucleus.connectionPoolingType", "None");
        props.setProperty("datanucleus.connectionPoolingType.nontx", "None");
    }

    pmf = JDOHelper.getPersistenceManagerFactory(props);
    JDOMetaStore.ulf = updateLoggerFactory;
}
 
開發者ID:bitnine-oss,項目名稱:octopus,代碼行數:24,代碼來源:JDOMetaStore.java

示例3: getPersistManager

import javax.jdo.JDOHelper; //導入方法依賴的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

示例4: prepareTestDB

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
public MetaStore prepareTestDB() {
  MetaStore metadb;
  try {
    Class.forName(driver).newInstance();
  } catch (InstantiationException | IllegalAccessException
          | ClassNotFoundException e) {
    e.printStackTrace();
  }

  Properties properties = TestUtility.createProperty();

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

  DBMeta dbMeta = TestQuery.createDBMeta();
  metadb = new MetaStore(dbMeta.getName(), pm);
  metadb.addDB(dbMeta);

  return metadb;
}
 
開發者ID:andyhehk,項目名稱:SecureDB,代碼行數:21,代碼來源:SdbSchemeRewriterTest.java

示例5: prepareTestDB

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
/**
 * Prepare a in-memory database for testing
 */
@Before
public void prepareTestDB() {
  try {
    Class.forName(driver).newInstance();
  } catch (InstantiationException | IllegalAccessException
          | ClassNotFoundException e) {
    e.printStackTrace();
  }

  Properties properties = new Properties();
  properties.setProperty("javax.jdo.option.ConnectionURL",
          "jdbc:derby:memory:test_db;create=true");
  properties.setProperty("javax.jdo.option.ConnectionDriverName",
          "org.apache.derby.jdbc.EmbeddedDriver");
  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");

  pmf = JDOHelper.getPersistenceManagerFactory(properties);
  pm = pmf.getPersistenceManager();
}
 
開發者ID:andyhehk,項目名稱:SecureDB,代碼行數:28,代碼來源:MetaStoreTest.java

示例6: prepareTestDB

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
public MetaStore prepareTestDB() {
  MetaStore metadb;
  try {
    Class.forName(driver).newInstance();
  } catch (InstantiationException | IllegalAccessException
          | ClassNotFoundException e) {
    e.printStackTrace();
  }

  Properties properties = TestUtility.createProperty();

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

  DBMeta dbMeta = TestQuery.createDBMetaSimple();
  metadb = new MetaStore(dbMeta.getName(), pm);
  metadb.addDB(dbMeta);

  return metadb;
}
 
開發者ID:andyhehk,項目名稱:SecureDB,代碼行數:21,代碼來源:SemanticAnalyzerTest.java

示例7: createDatastore

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@BeforeClass
public static void createDatastore() {
  Map<String, String> props = new HashMap<>();
  props.put("javax.jdo.option.ConnectionURL", "jdbc:hsqldb:mem:test");
  props.put("javax.jdo.option.ConnectionDriverName", "org.hsqldb.jdbcDriver");
  props.put("javax.jdo.option.ConnectionUserName", "sa");
  props.put("javax.jdo.option.ConnectionPassword", "");
  props.put("datanucleus.schema.autoCreateAll", "true");
  /*
   * The RetainValues option is important if we verify interaction involving objects which outlive
   * their persistence manager. While this should not happen during normal interaction, it does
   * happen when verifying interactions with mockito.
   */
  props.put("javax.jdo.option.RetainValues", "true");
  pmf = JDOHelper.getPersistenceManagerFactory(props, "core");
}
 
開發者ID:OsuCelebrity,項目名稱:OsuCelebrity,代碼行數:17,代碼來源:AbstractJDOTest.java

示例8: initPersistenceManagerFactoryAndPersistenceCapableClasses

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
private void initPersistenceManagerFactoryAndPersistenceCapableClasses(final boolean createRepository) {
	final Map<String, String> persistenceProperties = getPersistenceProperties(createRepository);
	persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory(persistenceProperties);
	final PersistenceManager pm = persistenceManagerFactory.getPersistenceManager();
	try {
		try {
			initPersistenceCapableClasses(pm);
		} catch (final Exception x) {
			if (x instanceof RuntimeException)
				throw (RuntimeException)x;
			else
				throw new RuntimeException(x);
		}
	} finally {
		if (pm != null)
			pm.close();
	}
}
 
開發者ID:cloudstore,項目名稱:cloudstore,代碼行數:19,代碼來源:LocalRepoManagerImpl.java

示例9: createPersistenceManager

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
/**
 * Creates a new JDO PersistenceManager.
 * @return a PersistenceManager
 */
public static PersistenceManager createPersistenceManager() {
    if (Config.isUnitTestsEnabled()) {
        pmf = JDOHelper.getPersistenceManagerFactory(JDO_OVERRIDES, "Alpine");
    }
    if (pmf == null) {
        throw new IllegalStateException("Context is not initialized yet.");
    }
    return pmf.getPersistenceManager();
}
 
開發者ID:stevespringett,項目名稱:Alpine,代碼行數:14,代碼來源:PersistenceManagerFactory.java

示例10: main

import javax.jdo.JDOHelper; //導入方法依賴的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

示例11: getPMF

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
public static PersistenceManagerFactory getPMF() {
	final Properties properties = commonProperties(false);
	properties.setProperty("javax.jdo.option.ConnectionURL", "jdbc:postgresql://localhost/mutinack_test_db");
	properties.setProperty("javax.jdo.option.ConnectionDriverName", "org.postgresql.Driver");
	properties.setProperty("javax.jdo.option.ConnectionUserName", "testuser3");
	properties.setProperty("javax.jdo.option.ConnectionPassword", "testpassword34");
	PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(properties);
	return pmf;
}
 
開發者ID:cinquin,項目名稱:mutinack,代碼行數:10,代碼來源:PMF.java

示例12: registerFactory

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
private void registerFactory(String clientName, String databaseName, DataSource ds) {
  	Properties connectionProperties = (Properties) dataNucleusProperties.clone();
  	connectionProperties.put("javax.jdo.option.ConnectionFactory", ds);
if (databaseName != null)
  		connectionProperties.setProperty("datanucleus.mapping.Catalog", databaseName);
  	logger.info("Adding PMF factory for client "+clientName+" with database "+databaseName);
      PersistenceManagerFactory factory = JDOHelper.getPersistenceManagerFactory(connectionProperties);
      factories.put(clientName, factory);
  }
 
開發者ID:SeldonIO,項目名稱:seldon-server,代碼行數:10,代碼來源:JDOFactory.java

示例13: SingletonConexion

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
/**
 * Constructor de la clase que nos garantiza que sea una unica instancia a
 * traves del singleton.
 */
public SingletonConexion() {
	singleton = Singleton.getInstance();
	String db=new IniFile("conf.ini").getParameters("db");
	Properties p = new Properties();
	try{
		if (db.equals("MYSQL"))	p.load(new FileInputStream("MYSQL.properties"));
		else p.load(new FileInputStream("POSTGRES.properties"));
		pmf = JDOHelper.getPersistenceManagerFactory(p);
	}catch (Exception e){
		pmf = JDOHelper.getPersistenceManagerFactory(db);
	}
}
 
開發者ID:lucianoit10,項目名稱:itRegistro,代碼行數:17,代碼來源:SingletonConexion.java

示例14: setup

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@Before
public void setup() throws Exception {
  dataDir = new File(Files.createTempDir(), "sentry_policy_db");
  Properties prop = new Properties();
  prop.setProperty(ServerConfig.JAVAX_JDO_URL, "jdbc:derby:;databaseName=" + dataDir.getPath() + ";create=true");
  prop.setProperty(ServerConfig.JAVAX_JDO_USER, "Sentry");
  prop.setProperty(ServerConfig.JAVAX_JDO_PASS, "Sentry");
  prop.setProperty(ServerConfig.JAVAX_JDO_DRIVER_NAME, "org.apache.derby.jdbc.EmbeddedDriver");
  prop.setProperty("datanucleus.autoCreateSchema", "true");
  prop.setProperty("datanucleus.fixedDatastore", "false");
  prop.setProperty("datanucleus.NontransactionalRead", "false");
  prop.setProperty("datanucleus.NontransactionalWrite", "false");
  pmf = JDOHelper.getPersistenceManagerFactory(prop);
}
 
開發者ID:apache,項目名稱:incubator-sentry,代碼行數:15,代碼來源:TestSentryRole.java

示例15: contextInitialized

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent event) {
    LOGGER.info("Initializing persistence framework");
    pmf = JDOHelper.getPersistenceManagerFactory("Alpine");
}
 
開發者ID:stevespringett,項目名稱:Alpine,代碼行數:6,代碼來源:PersistenceManagerFactory.java


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