Package javax.persistence

Examples of javax.persistence.EntityManagerFactory


        Index<EntityManagerFactory, Map> factories = deploymentInfo.getExtendedEntityManagerFactories();
        Index<EntityManagerFactory, EntityManager> entityManagers = null;
        if (factories != null && factories.size() > 0) {
            entityManagers = new Index<EntityManagerFactory, EntityManager>(new ArrayList<EntityManagerFactory>(factories.keySet()));
            for (Map.Entry<EntityManagerFactory, Map> entry : factories.entrySet()) {
                EntityManagerFactory entityManagerFactory = entry.getKey();
                Map properties = entry.getValue();


                EntityManager entityManager = entityManagerRegistry.getInheritedEntityManager(entityManagerFactory);
                if (entityManager == null) {
                    if (properties != null) {
                        entityManager = entityManagerFactory.createEntityManager(properties);
                    } else {
                        entityManager = entityManagerFactory.createEntityManager();
                    }
                }
                entityManagers.put(entityManagerFactory, entityManager);
            }
        }
View Full Code Here


        String unitName = unitNameAnnotation.value();

        Properties properties = persistenceConfigurationProvider.getEntityManagerFactoryConfiguration(unitName);

        EntityManagerFactory emf = Persistence.createEntityManagerFactory(unitName, properties);

        return emf;
    }
View Full Code Here

  @Inject
  protected BundleContext bundleContext;
  @Test
  public void findEntityManagerFactory() throws Exception {
    EntityManagerFactory emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", DEFAULT_TIMEOUT);
  }
View Full Code Here

    EntityManagerFactory emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", DEFAULT_TIMEOUT);
  }
 
  @Test
  public void findManagedContextFactory() throws Exception {
    EntityManagerFactory emf = null;
    try{
      getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))", 5000);
      fail("No context should exist");
View Full Code Here

  @Inject
  protected BundleContext bundleContext;
  @Test
  public void findEntityManagerFactory() throws Exception {
    EntityManagerFactory emf = getOsgiService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", DEFAULT_TIMEOUT);
  }
View Full Code Here

    public void testUnmarshallingMarshalledData() {
        HashMap<String, Object> testContext = null;
        List<MarshalledData> marshalledDataList = null;
        try {
            testContext = initializeMarshalledDataEMF(DROOLS_PERSISTENCE_UNIT_NAME, this.getClass(), true);
            EntityManagerFactory emf = (EntityManagerFactory) testContext.get(ENTITY_MANAGER_FACTORY);
            marshalledDataList = retrieveMarshallingData(emf);
        } finally {
            tearDown(testContext);
        }
View Full Code Here

    public void testUnmarshallingSpecificMarshalledData() {
        String testMethodAndSnapNum = "org.drools.persistence.session.RuleFlowGroupRollbackTest.testRuleFlowGroupRollback:1";
        // =
        // "org.kie.timer.integrationtests.TimerAndCalendarTest.testTimerRuleAfterIntReloadSession:1";
        HashMap<String, Object> testContext = initializeMarshalledDataEMF(DROOLS_PERSISTENCE_UNIT_NAME, this.getClass(), true);
        EntityManagerFactory emf = (EntityManagerFactory) testContext.get(ENTITY_MANAGER_FACTORY);
        List<MarshalledData> marshalledDataList = retrieveMarshallingData(emf);
        MarshalledData marshalledData = null;
        for (MarshalledData marshalledDataElement : marshalledDataList) {
            if (testMethodAndSnapNum.equals(marshalledDataElement.getTestMethodAndSnapshotNum())) {
                marshalledData = marshalledDataElement;
View Full Code Here

  public Map<String, AtomicInteger> usage =  new HashMap<String, AtomicInteger>();
 
  public EntityManagerFactory getEntityManagerFactory(String persistenceUnitName) {
    synchronized (this) {
      if (!registry.containsKey(persistenceUnitName)) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName);
        registry.put(persistenceUnitName, emf);
        usage.put(persistenceUnitName, new AtomicInteger(1));
        return emf;
      } else {
         incrementUsage(persistenceUnitName);
View Full Code Here

        return;
      }
     
      int count = decrementUsage(persistenceUnitName);
      if (count == 0) {
        EntityManagerFactory emf = registry.remove(persistenceUnitName);
        try {
           if (emf.isOpen()) emf.close();
        } catch (IllegalStateException e) {
           log.warn("Entity manager factory was already closed: " + persistenceUnitName);
        }
      }
    }
View Full Code Here

  @Override
  public String generate(TreeLogger logger, GeneratorContext context,
          String typeName) throws UnableToCompleteException {

    GWTUtil.populateMetaClassFactoryFromTypeOracle(context, logger);
    EntityManagerFactory emf = createHibernateEntityManagerFactory();
    try {
      final ClassStructureBuilder<?> classBuilder = generateEntityManagerClass(
              logger, context, emf);
      return classBuilder.getClassDefinition().getFullyQualifiedName();
    }
    finally {
      emf.close();
    }
  }
View Full Code Here

TOP

Related Classes of javax.persistence.EntityManagerFactory

Copyright © 2018 www.massapicom. 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.