@Override public OpenJPAEntityManagerSPI createEntityManager(Map props) { return createEntityManager(SynchronizationType.SYNCHRONIZED, props); }
/** * Supply delegate on construction. */ public EntityManagerFactoryImpl(BrokerFactory factory) { setBrokerFactory(factory); }
public OpenJPACriteriaBuilder getCriteriaBuilder() { return _emf.getCriteriaBuilder(); }
props = new HashMap(props); OpenJPAConfiguration conf = getConfiguration(); Log log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME); String user = (String) Configurations.removeProperty("ConnectionUserName", props); validateCfNameProps(conf, cfName, cf2Name); broker.setDetachedNew(false); OpenJPAEntityManagerSPI em = newEntityManagerImpl(broker);
/** * Constructor; supply delegate. */ public StoreCacheImpl(EntityManagerFactoryImpl emf, DataCache cache) { _repos = emf.getConfiguration().getMetaDataRepositoryInstance(); _cache = new DelegatingDataCache(cache, PersistenceExceptions.TRANSLATOR); }
public FetchPlan getFetchPlan() { assertNotCloseInvoked(); _broker.lock(); try { FetchConfiguration fc = _broker.getFetchConfiguration(); FetchPlan fp = _plans.get(fc); if (fp == null) { fp = _emf.toFetchPlan(_broker, fc); _plans.put(fc, fp); } return fp; } finally { _broker.unlock(); } }
EntityManager entityManager = emf.createEntityManager(); entityManager.close(); Collection<Class> classes = emf.getConfiguration().getMetaDataRepositoryInstance().loadPersistentTypes(true, classLoader); for (Class clazz : classes) { ClassMetaData classMetaData = emf.getConfiguration().getMetaDataRepositoryInstance().getMetaData(clazz, classLoader, true); String entityname = classMetaData.getDescribedType().getName(); if (!gps.hasMappingForEntityForIndex((entityname))) {
props = new HashMap(props); OpenJPAConfiguration conf = getConfiguration(); String user = (String) Configurations.removeProperty ("ConnectionUserName", props); OpenJPAEntityManagerSPI em = newEntityManagerImpl(broker);
public Metamodel getMetamodel() { return _emf.getMetamodel(); }
/** * Return the underlying broker factory for the given persistence manager * factory facade. */ public static BrokerFactory toBrokerFactory(EntityManagerFactory emf) { if (emf == null) return null; if (!(emf instanceof EntityManagerFactoryImpl)) { Class c = emf.getClass(); try { // either cast here may fail emf = (EntityManagerFactoryImpl) ((OpenJPAEntityManagerFactory) emf).getUserObject(EMF_KEY); } catch (ClassCastException cce) { throw new ArgumentException(_loc.get( "cant-convert-brokerfactory", c), null, null, false); } } return ((EntityManagerFactoryImpl) emf).getBrokerFactory(); }
/** * Return a persistence manager facade to the given broker retaining * previously associated persistence context type. */ public static OpenJPAEntityManager toEntityManager(Broker broker) { if (broker == null) return null; broker.lock(); try { OpenJPAEntityManager em = (OpenJPAEntityManager) broker.getUserObject(EM_KEY); if (em == null) { EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) toEntityManagerFactory(broker.getBrokerFactory()); em = emf.newEntityManagerImpl(broker); broker.putUserObject(EM_KEY, em); } return em; } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } finally { broker.unlock(); } }
public void injectLifecycle(EntityManagerFactory entityManagerFactory, JpaGpsDevice device) throws JpaGpsDeviceException { CompassGpsInterfaceDevice gps = (CompassGpsInterfaceDevice) device.getGps(); // TODO this should use OpenJPAEnitiyManagerFactorySPI, here for backward compatability with pre 1.0 EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) OpenJPAPersistence.cast(entityManagerFactory); if (eventListener == null) { eventListener = new OpenJPAEventListener(device); } if (useSpecificClassEvents) { ArrayList<Class> matchedClasses = new ArrayList<Class>(); Collection<Class> classes = emf.getConfiguration().getMetaDataRepositoryInstance().loadPersistentTypes(true, classLoader); for (Class clazz : classes) { ClassMetaData classMetaData = emf.getConfiguration().getMetaDataRepositoryInstance().getMetaData(clazz, classLoader, true); Class mappedClass = classMetaData.getDescribedType(); if (gps.hasMappingForEntityForMirror(mappedClass, Cascade.ALL)) { matchedClasses.add(mappedClass); } } if (matchedClasses.size() > 0) { emf.addLifecycleListener(eventListener, matchedClasses.toArray(new Class[0])); } } else { emf.addLifecycleListener(eventListener); } }
public OpenJPAQuery createDynamicQuery( org.apache.openjpa.persistence.query.QueryDefinition qdef) { String jpql = _emf.getDynamicQueryBuilder().toJPQL(qdef); return createQuery(jpql); }
public Cache getCache() { _factory.assertOpen(); return getStoreCache(); }
props = new HashMap(props); OpenJPAConfiguration conf = getConfiguration(); Log log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME); String user = (String) Configurations.removeProperty("ConnectionUserName", props); validateCfNameProps(conf, cfName, cf2Name); broker.setDetachedNew(false); OpenJPAEntityManagerSPI em = newEntityManagerImpl(broker);
public MetamodelImpl getMetamodel() { if (_metaModel == null) { _metaModel = new MetamodelImpl(getConfiguration() .getMetaDataRepositoryInstance()); } return _metaModel; }
public FetchPlan getFetchPlan() { assertNotCloseInvoked(); _broker.lock(); try { FetchConfiguration fc = _broker.getFetchConfiguration(); FetchPlan fp = _plans.get(fc); if (fp == null) { fp = _emf.toFetchPlan(_broker, fc); _plans.put(fc, fp); } return fp; } finally { _broker.unlock(); } }
public Metamodel getMetamodel() { return _emf.getMetamodel(); }
/** * Return the underlying broker factory for the given persistence manager * factory facade. */ public static BrokerFactory toBrokerFactory(EntityManagerFactory emf) { if (emf == null) return null; if (!(emf instanceof EntityManagerFactoryImpl)) { Class c = emf.getClass(); try { // either cast here may fail emf = (EntityManagerFactoryImpl) ((OpenJPAEntityManagerFactory) emf).getUserObject(EMF_KEY); } catch (ClassCastException cce) { throw new ArgumentException(_loc.get( "cant-convert-brokerfactory", c), null, null, false); } } return ((EntityManagerFactoryImpl) emf).getBrokerFactory(); }
/** * Return a persistence manager facade to the given broker retaining * previously associated persistence context type. */ public static OpenJPAEntityManager toEntityManager(Broker broker) { if (broker == null) return null; broker.lock(); try { OpenJPAEntityManager em = (OpenJPAEntityManager) broker.getUserObject(EM_KEY); if (em == null) { EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) toEntityManagerFactory(broker.getBrokerFactory()); em = emf.newEntityManagerImpl(broker); broker.putUserObject(EM_KEY, em); } return em; } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } finally { broker.unlock(); } }