Package javax.persistence

Examples of javax.persistence.SequenceGenerator


    catch ( ClassNotFoundException cnf ) {
      LOG.packageNotFound( packageName );
      return;
    }
    if ( pckg.isAnnotationPresent( SequenceGenerator.class ) ) {
      SequenceGenerator ann = pckg.getAnnotation( SequenceGenerator.class );
      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );
      if ( LOG.isTraceEnabled() ) {
        LOG.tracev( "Add sequence generator with name: {0}", idGen.getName() );
      }
View Full Code Here


      if ( LOG.isTraceEnabled() ) {
        LOG.tracev( "Add table generator with name: {0}", idGen.getName() );
      }
    }
    else if ( ann instanceof SequenceGenerator ) {
      SequenceGenerator seqGen = ( SequenceGenerator ) ann;
      idGen.setName( seqGen.name() );
      if ( useNewGeneratorMappings ) {
        idGen.setIdentifierGeneratorStrategy( SequenceStyleGenerator.class.getName() );

        if ( !BinderHelper.isEmptyAnnotationValue( seqGen.catalog() ) ) {
          idGen.addParam( PersistentIdentifierGenerator.CATALOG, seqGen.catalog() );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( seqGen.schema() ) ) {
          idGen.addParam( PersistentIdentifierGenerator.SCHEMA, seqGen.schema() );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( seqGen.sequenceName() ) ) {
          idGen.addParam( SequenceStyleGenerator.SEQUENCE_PARAM, seqGen.sequenceName() );
        }
        idGen.addParam( SequenceStyleGenerator.INCREMENT_PARAM, String.valueOf( seqGen.allocationSize() ) );
        idGen.addParam( SequenceStyleGenerator.INITIAL_PARAM, String.valueOf( seqGen.initialValue() ) );
      }
      else {
        idGen.setIdentifierGeneratorStrategy( "seqhilo" );

        if ( !BinderHelper.isEmptyAnnotationValue( seqGen.sequenceName() ) ) {
          idGen.addParam( org.hibernate.id.SequenceGenerator.SEQUENCE, seqGen.sequenceName() );
        }
        //FIXME: work on initialValue() through SequenceGenerator.PARAMETERS
        //    steve : or just use o.h.id.enhanced.SequenceStyleGenerator
        if ( seqGen.initialValue() != 1 ) {
          LOG.unsupportedInitialValue( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS );
        }
        idGen.addParam( SequenceHiLoGenerator.MAX_LO, String.valueOf( seqGen.allocationSize() - 1 ) );
        if ( LOG.isTraceEnabled() ) {
          LOG.tracev( "Add sequence generator with name: {0}", idGen.getName() );
        }
      }
    }
View Full Code Here

  }

  private static HashMap<String, IdGenerator> buildLocalGenerators(XAnnotatedElement annElt, Mappings mappings) {
    HashMap<String, IdGenerator> generators = new HashMap<String, IdGenerator>();
    TableGenerator tabGen = annElt.getAnnotation( TableGenerator.class );
    SequenceGenerator seqGen = annElt.getAnnotation( SequenceGenerator.class );
    GenericGenerator genGen = annElt.getAnnotation( GenericGenerator.class );
    if ( tabGen != null ) {
      IdGenerator idGen = buildIdGenerator( tabGen, mappings );
      generators.put( idGen.getName(), idGen );
    }
View Full Code Here

    catch (ClassNotFoundException cnf) {
      log.warn( "Package not found or wo package-info.java: {}", packageName );
      return;
    }
    if ( pckg.isAnnotationPresent( SequenceGenerator.class ) ) {
      SequenceGenerator ann = pckg.getAnnotation( SequenceGenerator.class );
      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );
      log.debug( "Add sequence generator with name: {}", idGen.getName() );
    }
    if ( pckg.isAnnotationPresent( TableGenerator.class ) ) {
View Full Code Here

      }
      idGen.addParam( TableHiLoGenerator.MAX_LO, String.valueOf( tabGen.allocationSize() - 1 ) );
      log.debug( "Add table generator with name: {}", idGen.getName() );
    }
    else if ( ann instanceof SequenceGenerator ) {
      SequenceGenerator seqGen = (SequenceGenerator) ann;
      idGen.setName( seqGen.name() );
      idGen.setIdentifierGeneratorStrategy( "seqhilo" );

      if ( !BinderHelper.isDefault( seqGen.sequenceName() ) ) {
        idGen.addParam( org.hibernate.id.SequenceGenerator.SEQUENCE, seqGen.sequenceName() );
      }
      //FIXME: work on initialValue() through SequenceGenerator.PARAMETERS
      if ( seqGen.initialValue() != 1 ) {
        log.warn(
            "Hibernate does not support SequenceGenerator.initialValue()"
        );
      }
      idGen.addParam( SequenceHiLoGenerator.MAX_LO, String.valueOf( seqGen.allocationSize() - 1 ) );
      log.debug( "Add sequence generator with name: {}", idGen.getName() );
    }
    else if ( ann instanceof GenericGenerator ) {
      GenericGenerator genGen = (GenericGenerator) ann;
      idGen.setName( genGen.name() );
View Full Code Here

  }

  private static HashMap<String, IdGenerator> buildLocalGenerators(XAnnotatedElement annElt, Mappings mappings) {
    HashMap<String, IdGenerator> generators = new HashMap<String, IdGenerator>();
    TableGenerator tabGen = annElt.getAnnotation( TableGenerator.class );
    SequenceGenerator seqGen = annElt.getAnnotation( SequenceGenerator.class );
    GenericGenerator genGen = annElt.getAnnotation( GenericGenerator.class );
    if ( tabGen != null ) {
      IdGenerator idGen = buildIdGenerator( tabGen, mappings );
      generators.put( idGen.getName(), idGen );
    }
View Full Code Here

    catch ( ClassNotFoundException cnf ) {
      LOG.packageNotFound( packageName );
      return;
    }
    if ( pckg.isAnnotationPresent( SequenceGenerator.class ) ) {
      SequenceGenerator ann = pckg.getAnnotation( SequenceGenerator.class );
      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );
      if ( LOG.isTraceEnabled() ) {
        LOG.tracev( "Add sequence generator with name: {0}", idGen.getName() );
      }
View Full Code Here

      if ( LOG.isTraceEnabled() ) {
        LOG.tracev( "Add table generator with name: {0}", idGen.getName() );
      }
    }
    else if ( ann instanceof SequenceGenerator ) {
      SequenceGenerator seqGen = ( SequenceGenerator ) ann;
      idGen.setName( seqGen.name() );
      if ( useNewGeneratorMappings ) {
        idGen.setIdentifierGeneratorStrategy( SequenceStyleGenerator.class.getName() );

        if ( !BinderHelper.isEmptyAnnotationValue( seqGen.catalog() ) ) {
          idGen.addParam( PersistentIdentifierGenerator.CATALOG, seqGen.catalog() );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( seqGen.schema() ) ) {
          idGen.addParam( PersistentIdentifierGenerator.SCHEMA, seqGen.schema() );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( seqGen.sequenceName() ) ) {
          idGen.addParam( SequenceStyleGenerator.SEQUENCE_PARAM, seqGen.sequenceName() );
        }
        idGen.addParam( SequenceStyleGenerator.INCREMENT_PARAM, String.valueOf( seqGen.allocationSize() ) );
        idGen.addParam( SequenceStyleGenerator.INITIAL_PARAM, String.valueOf( seqGen.initialValue() ) );
      }
      else {
        idGen.setIdentifierGeneratorStrategy( "seqhilo" );

        if ( !BinderHelper.isEmptyAnnotationValue( seqGen.sequenceName() ) ) {
          idGen.addParam( org.hibernate.id.SequenceGenerator.SEQUENCE, seqGen.sequenceName() );
        }
        //FIXME: work on initialValue() through SequenceGenerator.PARAMETERS
        //    steve : or just use o.h.id.enhanced.SequenceStyleGenerator
        if ( seqGen.initialValue() != 1 ) {
          LOG.unsupportedInitialValue( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS );
        }
        idGen.addParam( SequenceHiLoGenerator.MAX_LO, String.valueOf( seqGen.allocationSize() - 1 ) );
        if ( LOG.isTraceEnabled() ) {
          LOG.tracev( "Add sequence generator with name: {0}", idGen.getName() );
        }
      }
    }
View Full Code Here

    catch (ClassNotFoundException cnf) {
      log.warn( "Package not found or wo package-info.java: {}", packageName );
      return;
    }
    if ( pckg.isAnnotationPresent( SequenceGenerator.class ) ) {
      SequenceGenerator ann = pckg.getAnnotation( SequenceGenerator.class );
      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );
      log.trace( "Add sequence generator with name: {}", idGen.getName() );
    }
    if ( pckg.isAnnotationPresent( TableGenerator.class ) ) {
View Full Code Here

        idGen.addParam( TableHiLoGenerator.MAX_LO, String.valueOf( tabGen.allocationSize() - 1 ) );
      }
      log.trace( "Add table generator with name: {}", idGen.getName() );
    }
    else if ( ann instanceof SequenceGenerator ) {
      SequenceGenerator seqGen = (SequenceGenerator) ann;
      idGen.setName( seqGen.name() );
      if ( useNewGeneratorMappings ) {
        idGen.setIdentifierGeneratorStrategy( SequenceStyleGenerator.class.getName() );

        if ( !BinderHelper.isDefault( seqGen.catalog() ) ) {
          idGen.addParam( SequenceStyleGenerator.CATALOG, seqGen.catalog() );
        }
        if ( !BinderHelper.isDefault( seqGen.schema() ) ) {
          idGen.addParam( SequenceStyleGenerator.SCHEMA, seqGen.schema() );
        }
        if ( !BinderHelper.isDefault( seqGen.sequenceName() ) ) {
          idGen.addParam( SequenceStyleGenerator.SEQUENCE_PARAM, seqGen.sequenceName() );
        }
        idGen.addParam( SequenceStyleGenerator.INCREMENT_PARAM, String.valueOf( seqGen.allocationSize() ) );
        idGen.addParam( SequenceStyleGenerator.INITIAL_PARAM, String.valueOf( seqGen.initialValue() ) );
      }
      else {
        idGen.setIdentifierGeneratorStrategy( "seqhilo" );

        if ( !BinderHelper.isDefault( seqGen.sequenceName() ) ) {
          idGen.addParam( org.hibernate.id.SequenceGenerator.SEQUENCE, seqGen.sequenceName() );
        }
        //FIXME: work on initialValue() through SequenceGenerator.PARAMETERS
        //    steve : or just use o.h.id.enhanced.SequenceStyleGenerator
        if ( seqGen.initialValue() != 1 ) {
          log.warn(
              "Hibernate does not support SequenceGenerator.initialValue() unless '{}' set",
              AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS
          );
        }
        idGen.addParam( SequenceHiLoGenerator.MAX_LO, String.valueOf( seqGen.allocationSize() - 1 ) );
        log.trace( "Add sequence generator with name: {}", idGen.getName() );
      }
    }
    else if ( ann instanceof GenericGenerator ) {
      GenericGenerator genGen = (GenericGenerator) ann;
View Full Code Here

TOP

Related Classes of javax.persistence.SequenceGenerator

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.