Tabnine Logo
PersistenceAnnotationBeanPostProcessor.getPersistenceContext
Code IndexAdd Tabnine to your IDE (free)

How to use
getPersistenceContext
method
in
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor

Best Java code snippets using org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.getPersistenceContext (Showing top 6 results out of 315)

origin: spring-projects/spring-framework

  private EntityManager resolveExtendedEntityManager(Object target, @Nullable String requestingBeanName) {
    // Obtain EntityManager reference from JNDI?
    EntityManager em = getPersistenceContext(this.unitName, true);
    if (em == null) {
      // No pre-built EntityManager found -> build one based on factory.
      // Obtain EntityManagerFactory from JNDI?
      EntityManagerFactory emf = getPersistenceUnit(this.unitName);
      if (emf == null) {
        // Need to search for EntityManagerFactory beans.
        emf = findEntityManagerFactory(this.unitName, requestingBeanName);
      }
      // Inject a container-managed extended EntityManager.
      em = ExtendedEntityManagerCreator.createContainerManagedEntityManager(
          emf, this.properties, this.synchronizedWithTransaction);
    }
    if (em instanceof EntityManagerProxy && beanFactory != null && requestingBeanName != null &&
        beanFactory.containsBean(requestingBeanName) && !beanFactory.isPrototype(requestingBeanName)) {
      extendedEntityManagersToClose.put(target, ((EntityManagerProxy) em).getTargetEntityManager());
    }
    return em;
  }
}
origin: spring-projects/spring-framework

private EntityManager resolveEntityManager(@Nullable String requestingBeanName) {
  // Obtain EntityManager reference from JNDI?
  EntityManager em = getPersistenceContext(this.unitName, false);
  if (em == null) {
    // No pre-built EntityManager found -> build one based on factory.
    // Obtain EntityManagerFactory from JNDI?
    EntityManagerFactory emf = getPersistenceUnit(this.unitName);
    if (emf == null) {
      // Need to search for EntityManagerFactory beans.
      emf = findEntityManagerFactory(this.unitName, requestingBeanName);
    }
    // Inject a shared transactional EntityManager proxy.
    if (emf instanceof EntityManagerFactoryInfo &&
        ((EntityManagerFactoryInfo) emf).getEntityManagerInterface() != null) {
      // Create EntityManager based on the info's vendor-specific type
      // (which might be more specific than the field's type).
      em = SharedEntityManagerCreator.createSharedEntityManager(
          emf, this.properties, this.synchronizedWithTransaction);
    }
    else {
      // Create EntityManager based on the field's type.
      em = SharedEntityManagerCreator.createSharedEntityManager(
          emf, this.properties, this.synchronizedWithTransaction, getResourceType());
    }
  }
  return em;
}
origin: org.springframework/spring-orm

  private EntityManager resolveExtendedEntityManager(Object target, @Nullable String requestingBeanName) {
    // Obtain EntityManager reference from JNDI?
    EntityManager em = getPersistenceContext(this.unitName, true);
    if (em == null) {
      // No pre-built EntityManager found -> build one based on factory.
      // Obtain EntityManagerFactory from JNDI?
      EntityManagerFactory emf = getPersistenceUnit(this.unitName);
      if (emf == null) {
        // Need to search for EntityManagerFactory beans.
        emf = findEntityManagerFactory(this.unitName, requestingBeanName);
      }
      // Inject a container-managed extended EntityManager.
      em = ExtendedEntityManagerCreator.createContainerManagedEntityManager(
          emf, this.properties, this.synchronizedWithTransaction);
    }
    if (em instanceof EntityManagerProxy && beanFactory != null && requestingBeanName != null &&
        beanFactory.containsBean(requestingBeanName) && !beanFactory.isPrototype(requestingBeanName)) {
      extendedEntityManagersToClose.put(target, ((EntityManagerProxy) em).getTargetEntityManager());
    }
    return em;
  }
}
origin: org.springframework/spring-orm

private EntityManager resolveEntityManager(@Nullable String requestingBeanName) {
  // Obtain EntityManager reference from JNDI?
  EntityManager em = getPersistenceContext(this.unitName, false);
  if (em == null) {
    // No pre-built EntityManager found -> build one based on factory.
    // Obtain EntityManagerFactory from JNDI?
    EntityManagerFactory emf = getPersistenceUnit(this.unitName);
    if (emf == null) {
      // Need to search for EntityManagerFactory beans.
      emf = findEntityManagerFactory(this.unitName, requestingBeanName);
    }
    // Inject a shared transactional EntityManager proxy.
    if (emf instanceof EntityManagerFactoryInfo &&
        ((EntityManagerFactoryInfo) emf).getEntityManagerInterface() != null) {
      // Create EntityManager based on the info's vendor-specific type
      // (which might be more specific than the field's type).
      em = SharedEntityManagerCreator.createSharedEntityManager(
          emf, this.properties, this.synchronizedWithTransaction);
    }
    else {
      // Create EntityManager based on the field's type.
      em = SharedEntityManagerCreator.createSharedEntityManager(
          emf, this.properties, this.synchronizedWithTransaction, getResourceType());
    }
  }
  return em;
}
origin: apache/servicemix-bundles

  private EntityManager resolveExtendedEntityManager(Object target, @Nullable String requestingBeanName) {
    // Obtain EntityManager reference from JNDI?
    EntityManager em = getPersistenceContext(this.unitName, true);
    if (em == null) {
      // No pre-built EntityManager found -> build one based on factory.
      // Obtain EntityManagerFactory from JNDI?
      EntityManagerFactory emf = getPersistenceUnit(this.unitName);
      if (emf == null) {
        // Need to search for EntityManagerFactory beans.
        emf = findEntityManagerFactory(this.unitName, requestingBeanName);
      }
      // Inject a container-managed extended EntityManager.
      em = ExtendedEntityManagerCreator.createContainerManagedEntityManager(
          emf, this.properties, this.synchronizedWithTransaction);
    }
    if (em instanceof EntityManagerProxy && beanFactory != null && requestingBeanName != null &&
        beanFactory.containsBean(requestingBeanName) && !beanFactory.isPrototype(requestingBeanName)) {
      extendedEntityManagersToClose.put(target, ((EntityManagerProxy) em).getTargetEntityManager());
    }
    return em;
  }
}
origin: apache/servicemix-bundles

private EntityManager resolveEntityManager(@Nullable String requestingBeanName) {
  // Obtain EntityManager reference from JNDI?
  EntityManager em = getPersistenceContext(this.unitName, false);
  if (em == null) {
    // No pre-built EntityManager found -> build one based on factory.
    // Obtain EntityManagerFactory from JNDI?
    EntityManagerFactory emf = getPersistenceUnit(this.unitName);
    if (emf == null) {
      // Need to search for EntityManagerFactory beans.
      emf = findEntityManagerFactory(this.unitName, requestingBeanName);
    }
    // Inject a shared transactional EntityManager proxy.
    if (emf instanceof EntityManagerFactoryInfo &&
        ((EntityManagerFactoryInfo) emf).getEntityManagerInterface() != null) {
      // Create EntityManager based on the info's vendor-specific type
      // (which might be more specific than the field's type).
      em = SharedEntityManagerCreator.createSharedEntityManager(
          emf, this.properties, this.synchronizedWithTransaction);
    }
    else {
      // Create EntityManager based on the field's type.
      em = SharedEntityManagerCreator.createSharedEntityManager(
          emf, this.properties, this.synchronizedWithTransaction, getResourceType());
    }
  }
  return em;
}
org.springframework.orm.jpa.supportPersistenceAnnotationBeanPostProcessorgetPersistenceContext

Javadoc

Return a specified persistence context for the given unit name, as defined through the "persistenceContexts" (or "extendedPersistenceContexts") map.

Popular methods of PersistenceAnnotationBeanPostProcessor

  • <init>
  • buildPersistenceMetadata
  • findDefaultEntityManagerFactory
    Find a single default EntityManagerFactory in the Spring application context.
  • findEntityManagerFactory
    Find an EntityManagerFactory with the given name in the current Spring application context, falling
  • findNamedEntityManagerFactory
    Find an EntityManagerFactory with the given name in the current Spring application context.
  • findPersistenceMetadata
  • getPersistenceUnit
    Return a specified persistence unit for the given unit name, as defined through the "persistenceUnit
  • lookup
    Perform a JNDI lookup for the given resource by name.Called for EntityManagerFactory and EntityManag
  • postProcessProperties
  • postProcessMergedBeanDefinition
  • setDefaultPersistenceUnitName
    Specify the default persistence unit name, to be used in case of no unit name specified in an @Persi
  • setExtendedPersistenceContexts
    Specify the extended persistence contexts for EntityManager lookups, as a Map from persistence unit
  • setDefaultPersistenceUnitName,
  • setExtendedPersistenceContexts,
  • setJndiTemplate,
  • setPersistenceContexts,
  • setPersistenceUnits

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • setContentView (Activity)
  • startActivity (Activity)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • JList (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now