Examples of PersistenceConfiguration


Examples of org.datanucleus.PersistenceConfiguration

            }
        }

        // Initialise the context for JPA
        NucleusContext nucleusCtx = new NucleusContext("JPA", startupProps);
        PersistenceConfiguration propConfig = nucleusCtx.getPersistenceConfiguration();

        // Apply remaining persistence properties
        Map ctxProps = new HashMap();
        ctxProps.putAll(props);

        if (!props.containsKey("datanucleus.transactiontype") &&
            !props.containsKey("javax.jdo.option.transactiontype"))
        {
            // Default to RESOURCE_LOCAL txns
            ctxProps.put("datanucleus.transactiontype", TransactionType.RESOURCE_LOCAL.toString());
        }
        else
        {
            // let TransactionType.JTA imply ResourceType.JTA
            String transactionType = props.get("datanucleus.transactiontype") != null ?
                    (String)props.get("datanucleus.transactiontype") : (String)props.get("javax.jdo.option.transactiontype");
            if (TransactionType.JTA.toString().equalsIgnoreCase(transactionType))
            {
                ctxProps.put(ConnectionFactory.DATANUCLEUS_CONNECTION_RESOURCE_TYPE.toLowerCase(Locale.ENGLISH),
                    ConnectionResourceType.JTA.toString());
                ctxProps.put(ConnectionFactory.DATANUCLEUS_CONNECTION2_RESOURCE_TYPE.toLowerCase(Locale.ENGLISH),
                    ConnectionResourceType.JTA.toString());
            }
        }
        propConfig.setPersistenceProperties(ctxProps);

        // Load up the MetaData implied by this "persistence-unit"
        nucleusCtx.getMetaDataManager().loadPersistenceUnit(unitMetaData, null);
        nucleusCtx.initialise();

        // Load up any persistence-unit classes into the StoreManager
        boolean loadClasses = propConfig.getBooleanProperty("datanucleus.persistenceunitloadclasses");
        if (loadClasses)
        {
            // Load all classes into StoreManager so it knows about them
            Collection<String> loadedClasses = nucleusCtx.getMetaDataManager().getClassesWithMetaData();
            nucleusCtx.getStoreManager().addClasses(loadedClasses.toArray(new String[loadedClasses.size()]), nucleusCtx.getClassLoaderResolver(null));
View Full Code Here

Examples of org.datanucleus.PersistenceConfiguration

  public DatastoreManager(ClassLoaderResolver clr, NucleusContext nucContext, Map<String, Object> props)
      throws NoSuchFieldException, IllegalAccessException {
    super("appengine", clr, nucContext, props);

    // Override some of the default property values for AppEngine
    PersistenceConfiguration conf = nucContext.getPersistenceConfiguration();
    conf.setProperty("datanucleus.attachSameDatastore", Boolean.TRUE.toString()); // Always only one datastore
    // We'd like to respect the user's selection here, but the default value is 1.
    // This is problematic for us in the situation where, for example, an embedded object
    // gets updated more than once in a txn because we end up putting the same entity twice.
    // TODO(maxr) Remove this once we support multiple puts
    conf.setProperty("datanucleus.datastoreTransactionFlushLimit", Integer.MAX_VALUE);
    // Install our key translator
    conf.setProperty("datanucleus.identityKeyTranslatorType", "appengine");

    // Check if datastore api is in CLASSPATH.  Don't let the hard-coded
    // jar name upset you, it's just used for error messages.  The check will
    // succeed so long as the class is available on the classpath
    ClassUtils.assertClassForJarExistsInClasspath(
View Full Code Here

Examples of org.datanucleus.PersistenceConfiguration

   * @param resourceType Name of the resource ("appengine", "appengine-nontx")
   */
  public DatastoreConnectionFactoryImpl(StoreManager storeMgr, String resourceType) {
    super(storeMgr, resourceType);

    PersistenceConfiguration conf = storeMgr.getNucleusContext().getPersistenceConfiguration();
    if (conf.getProperty(DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY) == null) {
        // User hasn't configured the "auto-create" property, so set it
        conf.setProperty(DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY, Boolean.TRUE.toString());
    }
    this.isAutoCreateTransaction = conf.getBooleanProperty(AUTO_CREATE_TXNS_PROPERTY);
  }
View Full Code Here

Examples of org.datanucleus.PersistenceConfiguration

    persistenceHandler = new DatastorePersistenceHandler(this);
    dba = new DatastoreAdapter();
    initialiseIdentifierFactory(omfContext);
    setCustomPluginManager();
    addTypeManagerMappings();
    PersistenceConfiguration persistenceConfig = omfContext.getPersistenceConfiguration();
    storageVersion = StorageVersion.fromConfig(persistenceConfig);
    logConfiguration();
  }
View Full Code Here

Examples of org.datanucleus.PersistenceConfiguration

        pluginMgr, new DatastorePluginRegistry((PluginRegistry) registryField.get(pluginMgr)));
  }

  private static OMFContext addDefaultPropertyValues(OMFContext omfContext) {

    PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
    // There is only one datastore so set this to true no matter what.
    conf.setProperty("datanucleus.attachSameDatastore", Boolean.TRUE.toString());
    // Only set this if a value has not been provided
    if (conf.getProperty(DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY) == null) {
      conf.setProperty(
          DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY, Boolean.TRUE.toString());
    }
    // We'd like to respect the user's selection here, but the default value is 1.
    // This is problematic for us in the situation where, for example, an embedded object
    // gets updated more than once in a txn because we end up putting the same
    // entity twice.
    // TODO(maxr) Remove this once we support multiple puts
    conf.setProperty("datanucleus.datastoreTransactionFlushLimit", Integer.MAX_VALUE);
    /*
     * The DataNucleus query cache has a pretty nasty bug where it caches the symbol table along with
     * the compiled query.  The query cache uses weak references so it doesn't always happen, but if
     * you get a cache hit and your param values are different from the param values in the cached
     * symbol table, your query will execute with old param values and return incorrect results.
     */
    conf.setProperty("datanucleus.query.cached", false);
    return omfContext;
  }
View Full Code Here

Examples of org.datanucleus.PersistenceConfiguration

   * Method to create the IdentifierFactory to be used by this store.
   * Relies on the datastore adapter existing before creation
   * @param omfContext ObjectManagerFactory context
   */
  protected void initialiseIdentifierFactory(OMFContext omfContext) {
    PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
    String idFactoryName = conf.getStringProperty("datanucleus.identifierFactory");
    String idFactoryClassName = omfContext.getPluginManager()
        .getAttributeValueForExtension("org.datanucleus.store_identifierfactory",
            "name", idFactoryName, "class-name");
    if (idFactoryClassName == null) {
      throw new FatalNucleusUserException(idFactoryName);
View Full Code Here

Examples of org.datanucleus.PersistenceConfiguration

        pluginMgr, new DatastorePluginRegistry((PluginRegistry) registryField.get(pluginMgr)));
  }

  private static OMFContext addDefaultPropertyValues(OMFContext omfContext) {

    PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
    // There is only one datastore so set this to true no matter what.
    conf.setProperty("datanucleus.attachSameDatastore", Boolean.TRUE.toString());
    // Only set this if a value has not been provided
    if (conf.getProperty(DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY) == null) {
      conf.setProperty(
          DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY, Boolean.TRUE.toString());
    }
    // We'd like to respect the user's selection here, but the default value is 1.
    // This is problematic for us in the situation where, for example, an embedded object
    // gets updated more than once in a txn because we end up putting the same
    // entity twice.
    // TODO(maxr) Remove this once we support multiple puts
    conf.setProperty("datanucleus.datastoreTransactionFlushLimit", Integer.MAX_VALUE);
    /*
     * The DataNucleus query cache has a pretty nasty bug where it caches the symbol table along with
     * the compiled query.  The query cache uses weak references so it doesn't always happen, but if
     * you get a cache hit and your param values are different from the param values in the cached
     * symbol table, your query will execute with old param values and return incorrect results.
     */
    conf.setProperty("datanucleus.query.cached", false);
    return omfContext;
  }
View Full Code Here

Examples of org.datanucleus.PersistenceConfiguration

   * Method to create the IdentifierFactory to be used by this store.
   * Relies on the datastore adapter existing before creation
   * @param omfContext ObjectManagerFactory context
   */
  protected void initialiseIdentifierFactory(OMFContext omfContext) {
    PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
    String idFactoryName = conf.getStringProperty("datanucleus.identifierFactory");
    String idFactoryClassName = omfContext.getPluginManager()
        .getAttributeValueForExtension("org.datanucleus.store_identifierfactory",
            "name", idFactoryName, "class-name");
    if (idFactoryClassName == null) {
      throw new FatalNucleusUserException(idFactoryName);
View Full Code Here

Examples of org.datanucleus.PersistenceConfiguration

    persistenceHandler = new DatastorePersistenceHandler(this);
    dba = new DatastoreAdapter();
    initialiseIdentifierFactory(omfContext);
    setCustomPluginManager();
    addTypeManagerMappings();
    PersistenceConfiguration persistenceConfig = omfContext.getPersistenceConfiguration();
    storageVersion = StorageVersion.fromConfig(persistenceConfig);
    logConfiguration();
  }
View Full Code Here

Examples of org.datanucleus.PersistenceConfiguration

        pluginMgr, new DatastorePluginRegistry((PluginRegistry) registryField.get(pluginMgr)));
  }

  private static OMFContext addDefaultPropertyValues(OMFContext omfContext) {

    PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
    // There is only one datastore so set this to true no matter what.
    conf.setProperty("datanucleus.attachSameDatastore", Boolean.TRUE.toString());
    // Only set this if a value has not been provided
    if (conf.getProperty(DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY) == null) {
      conf.setProperty(
          DatastoreConnectionFactoryImpl.AUTO_CREATE_TXNS_PROPERTY, Boolean.TRUE.toString());
    }
    // We'd like to respect the user's selection here, but the default value is 1.
    // This is problematic for us in the situation where, for example, an embedded object
    // gets updated more than once in a txn because we end up putting the same
    // entity twice.
    // TODO(maxr) Remove this once we support multiple puts
    conf.setProperty("datanucleus.datastoreTransactionFlushLimit", Integer.MAX_VALUE);
    /*
     * The DataNucleus query cache has a pretty nasty bug where it caches the symbol table along with
     * the compiled query.  The query cache uses weak references so it doesn't always happen, but if
     * you get a cache hit and your param values are different from the param values in the cached
     * symbol table, your query will execute with old param values and return incorrect results.
     */
    conf.setProperty("datanucleus.query.cached", false);
    return omfContext;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.