本文整理汇总了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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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");
}
示例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();
}
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例15: contextInitialized
import javax.jdo.JDOHelper; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent event) {
LOGGER.info("Initializing persistence framework");
pmf = JDOHelper.getPersistenceManagerFactory("Alpine");
}