コード例 #1
0
 @SuppressWarnings("deprecation")
 @Override
 public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) {
   putPropertyIfAbsent(pu, properties, Configuration.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
   putPropertyIfAbsent(
       pu,
       properties,
       org.hibernate.ejb.AvailableSettings.SCANNER,
       HibernateAnnotationScanner.class.getName());
   properties.put(AvailableSettings.APP_CLASSLOADER, pu.getClassLoader());
   putPropertyIfAbsent(pu, properties, AvailableSettings.JTA_PLATFORM, appServerJtaPlatform);
   properties.remove(
       AvailableSettings
           .TRANSACTION_MANAGER_STRATEGY); // remove legacy way of specifying TX manager (conflicts
   // with JTA_PLATFORM)
   putPropertyIfAbsent(
       pu,
       properties,
       org.hibernate.ejb.AvailableSettings.ENTITY_MANAGER_FACTORY_NAME,
       pu.getScopedPersistenceUnitName());
   putPropertyIfAbsent(
       pu, properties, AvailableSettings.SESSION_FACTORY_NAME, pu.getScopedPersistenceUnitName());
   if (!pu.getProperties().containsKey(AvailableSettings.SESSION_FACTORY_NAME)) {
     putPropertyIfAbsent(
         pu, properties, AvailableSettings.SESSION_FACTORY_NAME_IS_JNDI, Boolean.FALSE);
   }
 }
コード例 #2
0
  /**
   * determine if management console can display the second level cache entries
   *
   * @param pu
   * @return false if a custom AvailableSettings.CACHE_REGION_PREFIX property is specified. true if
   *     the scoped persistence unit name is used to prefix cache entries.
   */
  @Override
  public boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu) {
    String cacheRegionPrefix =
        pu.getProperties().getProperty(AvailableSettings.CACHE_REGION_PREFIX);

    return cacheRegionPrefix == null || cacheRegionPrefix.equals(pu.getScopedPersistenceUnitName());
  }
コード例 #3
0
 @Override
 public void addProviderDependencies(
     ServiceRegistry registry,
     ServiceTarget target,
     ServiceBuilder<?> builder,
     PersistenceUnitMetadata pu) {
   Properties properties = pu.getProperties();
   if (Boolean.parseBoolean(properties.getProperty(AvailableSettings.USE_SECOND_LEVEL_CACHE))) {
     HibernateSecondLevelCache.addSecondLevelCacheDependencies(registry, target, builder, pu);
   }
 }
コード例 #4
0
 private void putPropertyIfAbsent(
     PersistenceUnitMetadata pu, Map properties, String property, Object value) {
   if (!pu.getProperties().containsKey(property)) {
     properties.put(property, value);
   }
 }