Package org.hibernate.ogm.model.key.spi

Examples of org.hibernate.ogm.model.key.spi.IdSourceKey


  @Test
  public void shoulReadAndWriteSequenceInClusteredMode() throws Exception {
    // given
    IdSourceKeyMetadata keyMetadata = IdSourceKeyMetadata.forTable( "Hibernate_Sequences", "sequence_name", "next_val" );
    IdSourceKey key = IdSourceKey.forTable( keyMetadata, "Foo_Sequence" );

    // when
    Number value = dialect1.nextValue( new NextValueRequest( key, 1, 1 ) );
    assertThat( value ).isEqualTo( 1L );
View Full Code Here


    dialect = new EhcacheDialect( datastoreProvider );
  }

  @Test
  public void testIsThreadSafe() throws InterruptedException {
    final IdSourceKey test = IdSourceKey.forTable( IdSourceKeyMetadata.forTable( "sequences", "key", "next_val" ), "my_sequence" );
    Thread[] threads = new Thread[THREADS];
    for ( int i = 0; i < threads.length; i++ ) {
      threads[i] = new Thread(
          new Runnable() {
            @Override
View Full Code Here

  @Test
  public void shouldSerializeAndDeserializeRowKey() throws Exception {
    IdSourceKeyMetadata keyMetadata = IdSourceKeyMetadata.forTable( "Hibernate_Sequences", "sequence_name", "next_val" );

    // given
    IdSourceKey key = IdSourceKey.forTable( keyMetadata, "Foo_Sequence" );

    // when
    byte[] bytes = externalizerHelper.marshall( key );
    IdSourceKey unmarshalledKey = externalizerHelper.unmarshall( bytes );

    // then
    assertThat( unmarshalledKey.getTable() ).isEqualTo( key.getTable() );
    assertThat( unmarshalledKey.getColumnNames() ).isEqualTo( key.getColumnNames() );
    assertThat( unmarshalledKey.getColumnValues() ).isEqualTo( key.getColumnValues() );

    assertTrue( key.equals( unmarshalledKey ) );
    assertTrue( unmarshalledKey.equals( key ) );
    assertThat( unmarshalledKey.hashCode() ).isEqualTo( key.hashCode() );
  }
View Full Code Here

    Files.delete( new File( dbLocation ) );
  }

  @Test
  public void testFirstValueIsInitialValue() {
    final IdSourceKey generatorKey = buildIdGeneratorKey( INITIAL_VALUE_SEQUENCE );
    Number sequenceValue = dialect.nextValue( new NextValueRequest( generatorKey, 1, INITIAL_VALUE_FIRST_VALUE_TEST ) );
    assertThat( sequenceValue ).isEqualTo( INITIAL_VALUE_FIRST_VALUE_TEST );
  }
View Full Code Here

    assertThat( sequenceValue ).isEqualTo( INITIAL_VALUE_FIRST_VALUE_TEST );
  }

  @Test
  public void testThreadSafety() throws InterruptedException {
    final IdSourceKey generatorKey = buildIdGeneratorKey( THREAD_SAFETY_SEQUENCE );
    Thread[] threads = new Thread[THREADS];
    for ( int i = 0; i < threads.length; i++ ) {
      threads[i] = new Thread( new Runnable() {
        @Override
        public void run() {
View Full Code Here

    Serializable generatedValue = session.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork( work, workInTransaction );
    return generatedValue;
  }

  private IntegralDataTypeHolder doWorkInCurrentTransactionIfAny(SessionImplementor session) {
    IdSourceKey key = getGeneratorKey( session );

    Number nextValue = gridDialect.nextValue(
        new NextValueRequest(
            key,
            optimizer.applyIncrementSizeToSourceValues() ? incrementSize : 1,
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.model.key.spi.IdSourceKey

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.