Package org.hibernate.ogm.options.spi

Examples of org.hibernate.ogm.options.spi.OptionsContext


        .property( "temperature", ElementType.FIELD )
          .embed( "Embedded" );

    setupSessionFactory( configuration );

    OptionsContext temperatureOptions = getOptionsContext().getPropertyOptions( Refrigerator.class, "temperature" );
    assertThat( temperatureOptions.getUnique( EmbedExampleOption.class ) ).isEqualTo( "Embedded" );
  }
View Full Code Here


    assertOptionsSetViaConfigurator();
  }

  private void assertOptionsSetViaConfigurator() {
    OptionsContext refrigatorOptions = getOptionsContext().getEntityOptions( Refrigerator.class );
    assertThat( refrigatorOptions.getUnique( ForceExampleOption.class ) ).isTrue();

    OptionsContext microwaveOptions = getOptionsContext().getEntityOptions( Microwave.class );
    assertThat( microwaveOptions.getUnique( NameExampleOption.class ) ).isEqualTo( "test" );

    OptionsContext temperatureOptions = getOptionsContext().getPropertyOptions( Refrigerator.class, "temperature" );
    assertThat( temperatureOptions.getUnique( EmbedExampleOption.class ) ).isEqualTo( "Embedded" );
  }
View Full Code Here

  @Test
  public void shouldApplyOptionConfiguratorSpecifiedInPersistenceXml() throws Exception {
    final EntityManagerFactory emf = Persistence.createEntityManagerFactory( "jpajtastandalone-options" );
    OptionsServiceContext optionsContext = getOptionsContext( emf );

    OptionsContext refrigatorOptions = optionsContext.getEntityOptions( Refrigerator.class );
    assertThat( refrigatorOptions.getUnique( ForceExampleOption.class ) ).isTrue();

    OptionsContext microwaveOptions = optionsContext.getEntityOptions( Microwave.class );
    assertThat( microwaveOptions.getUnique( NameExampleOption.class ) ).isEqualTo( "test" );

    OptionsContext temperatureOptions = optionsContext.getPropertyOptions( Refrigerator.class, "temperature" );
    assertThat( temperatureOptions.getUnique( EmbedExampleOption.class ) ).isEqualTo( "Embedded" );

    dropSchemaAndDatabase( emf );
    emf.close();
  }
View Full Code Here

      return globalOptions;
    }

    @Override
    public OptionsContext getEntityOptions(Class<?> entityType) {
      OptionsContext entityOptions = entityContexts.get( entityType );

      if ( entityOptions == null ) {
        entityOptions = getAndCacheEntityOptions( entityType );
      }
View Full Code Here

    }

    @Override
    public OptionsContext getPropertyOptions(Class<?> entityType, String propertyName) {
      PropertyKey key = new PropertyKey( entityType, propertyName );
      OptionsContext propertyOptions = propertyContexts.get( key );

      if ( propertyOptions == null ) {
        propertyOptions = getAndCachePropertyOptions( key );
      }
View Full Code Here

      return propertyOptions;
    }

    private OptionsContext getAndCacheEntityOptions(Class<?> entityType) {
      OptionsContext entityOptions = OptionsContextImpl.forEntity( sources, entityType );

      OptionsContext cachedOptions = entityContexts.putIfAbsent( entityType, entityOptions );
      if ( cachedOptions != null ) {
        entityOptions = cachedOptions;
      }

      return entityOptions;
View Full Code Here

      return entityOptions;
    }

    private OptionsContext getAndCachePropertyOptions(PropertyKey key) {
      OptionsContext propertyOptions = OptionsContextImpl.forProperty( sources, key.getEntity(), key.getProperty() );

      OptionsContext cachedOptions = propertyContexts.putIfAbsent( key, propertyOptions );
      if ( cachedOptions != null ) {
        propertyOptions = cachedOptions;
      }

      return propertyOptions;
View Full Code Here

      return globalOptions;
    }

    @Override
    public OptionsContext getEntityOptions(Class<?> entityType) {
      OptionsContext entityOptions = entityContexts.get( entityType );

      if ( entityOptions == null ) {
        entityOptions = getAndCacheEntityOptions( entityType );
      }
View Full Code Here

    }

    @Override
    public OptionsContext getPropertyOptions(Class<?> entityType, String propertyName) {
      PropertyKey key = new PropertyKey( entityType, propertyName );
      OptionsContext propertyOptions = propertyContexts.get( key );

      if ( propertyOptions == null ) {
        propertyOptions = getAndCachePropertyOptions( key );
      }
View Full Code Here

      return propertyOptions;
    }

    private OptionsContext getAndCacheEntityOptions(Class<?> entityType) {
      OptionsContext entityOptions = OptionsContextImpl.forEntity( sources, entityType );

      OptionsContext cachedOptions = entityContexts.putIfAbsent( entityType, entityOptions );
      if ( cachedOptions != null ) {
        entityOptions = cachedOptions;
      }

      return entityOptions;
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.options.spi.OptionsContext

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.