/** * Get the properties and associated values that are in effect for the entity manager factory. * Changing the contents of the map does not change the configuration in effect. * @return properties */ public Map<String, Object> getProperties() { return pmf.getOMFContext().getPersistenceConfiguration().getPersistenceProperties(); }
/** * Get the properties and associated values that are in effect for the entity manager factory. * Changing the contents of the map does not change the configuration in effect. * @return properties */ public Map getProperties() { PersistenceConfiguration conf = ((ObjectManagerFactoryImpl)pmf).getOMFContext().getPersistenceConfiguration(); return conf.getOptions(); }
/** * Get the names of the properties that are supported for use with the entity manager factory. * These correspond to properties that may be passed to the methods of the EntityManagerFactory * interface that take a properties argument. These include all standard properties as well as * vendor-specific properties supported by the provider. These properties may or may not currently * be in effect. * @return properties and hints */ public Set<String> getSupportedProperties() { return pmf.getOMFContext().getPersistenceConfiguration().getSupportedProperties(); }
/** * Creates an object manager with datastore credentials. * * @param omf the object manager factory * @param owner the owning persistence manager or entity manager * @param userName the username to the datastore * @param password the password to the datastore */ public ForceObjectManagerImpl(ObjectManagerFactoryImpl omf, Object owner, String userName, String password) { super(omf, owner, userName, password); this.allOrNothingEnabled = omf.getOMFContext().getPersistenceConfiguration().getBooleanProperty("force.AllOrNothing"); }
/** * Creates an object manager with datastore credentials. * * @param omf the object manager factory * @param owner the owning persistence manager or entity manager * @param userName the username to the datastore * @param password the password to the datastore */ public ForceObjectManagerImpl(ObjectManagerFactoryImpl omf, Object owner, String userName, String password) { super(omf, owner, userName, password); this.allOrNothingEnabled = omf.getOMFContext().getPersistenceConfiguration().getBooleanProperty("force.AllOrNothing"); }
/** * Get the names of the properties that are supported for use with the entity manager factory. * These correspond to properties that may be passed to the methods of the EntityManagerFactory * interface that take a properties argument. These include all standard properties as well as * vendor-specific properties supported by the provider. These properties may or may not currently * be in effect. * @return properties and hints */ @SuppressWarnings("unchecked") public Set<String> getSupportedProperties() { PersistenceConfiguration conf = ((ObjectManagerFactoryImpl)pmf).getOMFContext().getPersistenceConfiguration(); return conf.getSupportedOptions(); }
/** * Check if class is persistence aware, by looking at annotations * @param cls the Class * @return true if the class has @PersistenceAware */ protected boolean isClassPersistenceAware(Class cls) { String jpaLevel = mgr.getOMFContext().getPersistenceConfiguration().getStringProperty("datanucleus.jpa.level"); if (jpaLevel.equalsIgnoreCase("DataNucleus")) { AnnotationObject[] annotations = getClassAnnotationsForClass(cls); for (int i = 0; i < annotations.length; i++) { String annName = annotations[i].getName(); if (annName.equals(JPAAnnotationUtils.PERSISTENCE_AWARE)) { return true; } } } return false; } }
PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration(); if (conf.hasProperty("javax.persistence.validation.mode"))
/** * Convenience method to throw the supplied exception. * If the supplied exception is a PersistenceException, also mark the current transaction for rollback. * @param re The exception */ private Object throwException(RuntimeException re) { if (re instanceof PersistenceException) { PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration(); boolean markForRollback = conf.getBooleanProperty("datanucleus.jpa.txnMarkForRollbackOnException"); if (markForRollback) { // The JPA spec says that all PersistenceExceptions thrown should mark the transaction for // rollback. Seems excessive to me. For example, you try to find an object with a particular id and it // doesn't exist so you then have to rollback the txn and start again. getTransaction().setRollbackOnly(); } } throw re; } }
/** * Convenience method to throw the supplied exception. * If the supplied exception is a PersistenceException, also mark the current transaction for rollback. * @param re The exception */ private Object throwException(RuntimeException re) { if (re instanceof PersistenceException) { PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration(); boolean markForRollback = conf.getBooleanProperty("datanucleus.jpa.txnMarkForRollbackOnException"); if (markForRollback) { // The JPA spec says that all PersistenceExceptions thrown should mark the transaction for // rollback. Seems excessive to me. For example, you try to find an object with a particular id and it // doesn't exist so you then have to rollback the txn and start again. getTransaction().setRollbackOnly(); } } throw re; } }
/** * Convenience method to throw the supplied exception. * If the supplied exception is a PersistenceException then also marks the current transaction for rollback. * @param re The exception */ private Object throwException(RuntimeException re) { if (re instanceof PersistenceException) { PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration(); boolean markForRollback = conf.getBooleanProperty("datanucleus.jpa.txnMarkForRollbackOnException"); if (markForRollback) { // The JPA spec says that all PersistenceExceptions thrown should mark the transaction for // rollback. Seems stupid to me. e.g you try to find an object with a particular id and it // doesn't exist so you then have to rollback the txn and start again. FFS. getTransaction().setRollbackOnly(); } } throw re; }
pmf.getOMFContext().getPersistenceConfiguration().getBooleanObjectProperty("datanucleus.singletonPMFForName"); if (singleton != null && singleton) {
pmf.getOMFContext().getPersistenceConfiguration().getBooleanObjectProperty("datanucleus.singletonPMFForName"); if (singleton != null && singleton) {
/** * Constructor. * @param emf The parent EntityManagerFactory * @param pmf The underlying PersistenceManagerFactory that handles persistence * @param contextType The Persistence Context type */ public EntityManagerImpl(EntityManagerFactory emf, PersistenceManagerFactory pmf, PersistenceContextType contextType) { this.emf = emf; // Allocate our ObjectManager // TODO Remove the PM when we disconnect StateManager from PersistenceManager pm = pmf.getPersistenceManager(); om = ((JDOPersistenceManager)pm).getObjectManager(); ObjectManagerFactoryImpl omf = (ObjectManagerFactoryImpl)pmf; if (omf.getOMFContext().getPersistenceConfiguration().getStringProperty("datanucleus.TransactionType").equalsIgnoreCase( TransactionType.RESOURCE_LOCAL.toString())) { // Using ResourceLocal transaction so allocate a transaction tx = new EntityTransactionImpl(om); } }
/** * Instantiates the connections to the Force.com service. It either reads the configs * from thread local (which would have been set from OAuth) or it gets the config from * the store manager. * {@inheritDoc} */ @Override public ManagedConnection createManagedConnection(Object poolKey, Map transactionOptions) { ForceStoreManager storeManager = (ForceStoreManager) omfContext.getStoreManager(); ForceServiceConnector connector = new ForceServiceConnector(); // A ConnectorConfig might have been set via OAuth in which case we should be // using that. ForceConnectorConfig tlConfig; if ((tlConfig = ForceServiceConnector.getThreadLocalConnectorConfig()) != null) { connector.setConnectorConfig(tlConfig); } else { connector.setConnectorConfig(storeManager.getConfig()); } connector.setConnectionName(omfContext.getPersistenceConfiguration().getStringProperty("force.ConnectionName")); connector.setClientId(ForceServiceConnector.API_USER_AGENT); connector.setTimeout(omfContext.getPersistenceConfiguration().getIntProperty("datanucleus.datastoreReadTimeout")); connector.setSkipCache(omfContext.getPersistenceConfiguration() .getBooleanProperty("force.skipConfigCache", false /* resultIfNotSet */)); return new ForceManagedConnection(connector); } }
/** * Instantiates the connections to the Force.com service. It either reads the configs * from thread local (which would have been set from OAuth) or it gets the config from * the store manager. * {@inheritDoc} */ @Override public ManagedConnection createManagedConnection(Object poolKey, Map transactionOptions) { ForceStoreManager storeManager = (ForceStoreManager) omfContext.getStoreManager(); ForceServiceConnector connector = new ForceServiceConnector(); // A ConnectorConfig might have been set via OAuth in which case we should be // using that. ForceConnectorConfig tlConfig; if ((tlConfig = ForceServiceConnector.getThreadLocalConnectorConfig()) != null) { connector.setConnectorConfig(tlConfig); } else { connector.setConnectorConfig(storeManager.getConfig()); } connector.setConnectionName(omfContext.getPersistenceConfiguration().getStringProperty("force.ConnectionName")); connector.setClientId(ForceServiceConnector.API_USER_AGENT); connector.setTimeout(omfContext.getPersistenceConfiguration().getIntProperty("datanucleus.datastoreReadTimeout")); connector.setSkipCache(omfContext.getPersistenceConfiguration() .getBooleanProperty("force.skipConfigCache", false /* resultIfNotSet */)); return new ForceManagedConnection(connector); } }
/** * * @param clr * @param conf */ public BeanValidatorHandler(ObjectManager om) { ValidatorFactory factory; conf = om.getOMFContext().getPersistenceConfiguration(); clr = om.getClassLoaderResolver(); if (conf.hasProperty("javax.persistence.validation.factory")) { //create from javax.persistence.validation.factory if given factory = (ValidatorFactory) conf.getProperty("javax.persistence.validation.factory"); } else { factory = Validation.buildDefaultValidatorFactory(); } validator = factory.usingContext().traversableResolver(new JPATraversalResolver(om)).getValidator(); }
.getPersistenceConfiguration().getIntProperty("datanucleus.maxFetchDepth"); if (maxDepth > 5) { throw new NucleusException("Max fetch depth cannot be greater than 5.");
.getPersistenceConfiguration().getIntProperty("datanucleus.maxFetchDepth"); if (maxDepth > 5) { throw new NucleusException("Max fetch depth cannot be greater than 5.");
/** * Constructor. * @param emf The parent EntityManagerFactory * @param pmf The underlying PersistenceManagerFactory that handles persistence * @param contextType The Persistence Context type */ public EntityManagerImpl(EntityManagerFactory emf, PersistenceManagerFactory pmf, PersistenceContextType contextType) { this.emf = emf; this.persistenceContextType = contextType; // Allocate our ObjectManager // TODO Remove the PM when we disconnect StateManager from PersistenceManager pm = pmf.getPersistenceManager(); om = ((JDOPersistenceManager)pm).getObjectManager(); ObjectManagerFactoryImpl omf = (ObjectManagerFactoryImpl)pmf; if (omf.getOMFContext().getPersistenceConfiguration().getStringProperty("datanucleus.TransactionType").equalsIgnoreCase( TransactionType.RESOURCE_LOCAL.toString())) { // Using ResourceLocal transaction so allocate a transaction tx = new EntityTransactionImpl(om); } CallbackHandler beanValidator = BeanValidatorHandlerFactory.newInstance(om); if (beanValidator!=null) { om.getCallbackHandler().addListener(beanValidator, null); } fetchPlan = new JPAFetchPlan(om.getFetchPlan()); }