Package javax.persistence

Examples of javax.persistence.TableGenerator


    Element element = tree != null ? tree.element( annotationToXml.get( TableGenerator.class ) ) : null;
    if ( element != null ) {
      return buildTableGeneratorAnnotation( element, defaults );
    }
    else if ( defaults.canUseJavaAnnotations() && isJavaAnnotationPresent( TableGenerator.class ) ) {
      TableGenerator tableAnn = getJavaAnnotation( TableGenerator.class );
      if ( StringHelper.isNotEmpty( defaults.getSchema() )
          || StringHelper.isNotEmpty( defaults.getCatalog() ) ) {
        AnnotationDescriptor annotation = new AnnotationDescriptor( TableGenerator.class );
        annotation.setValue( "name", tableAnn.name() );
        annotation.setValue( "table", tableAnn.table() );
        annotation.setValue( "catalog", tableAnn.table() );
        if ( StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) )
            && StringHelper.isNotEmpty( defaults.getCatalog() ) ) {
          annotation.setValue( "catalog", defaults.getCatalog() );
        }
        annotation.setValue( "schema", tableAnn.table() );
        if ( StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) )
            && StringHelper.isNotEmpty( defaults.getSchema() ) ) {
          annotation.setValue( "catalog", defaults.getSchema() );
        }
        annotation.setValue( "pkColumnName", tableAnn.pkColumnName() );
        annotation.setValue( "valueColumnName", tableAnn.valueColumnName() );
        annotation.setValue( "pkColumnValue", tableAnn.pkColumnValue() );
        annotation.setValue( "initialValue", tableAnn.initialValue() );
        annotation.setValue( "allocationSize", tableAnn.allocationSize() );
        annotation.setValue( "uniqueConstraints", tableAnn.uniqueConstraints() );
        return AnnotationFactory.create( annotation );
      }
      else {
        return tableAnn;
      }
View Full Code Here


      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );
      log.debug( "Add sequence generator with name: {}", idGen.getName() );
    }
    if ( pckg.isAnnotationPresent( TableGenerator.class ) ) {
      TableGenerator ann = pckg.getAnnotation( TableGenerator.class );
      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );

    }
    bindGenericGenerators(pckg, mappings);
View Full Code Here

    }
    if ( ann == null ) {
      idGen = null;
    }
    else if ( ann instanceof TableGenerator ) {
      TableGenerator tabGen = (TableGenerator) ann;
      idGen.setName( tabGen.name() );
      idGen.setIdentifierGeneratorStrategy( MultipleHiLoPerTableGenerator.class.getName() );

      if ( !BinderHelper.isDefault( tabGen.table() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.ID_TABLE, tabGen.table() );
      }
      if ( !BinderHelper.isDefault( tabGen.catalog() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.CATALOG, tabGen.catalog() );
      }
      if ( !BinderHelper.isDefault( tabGen.schema() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.SCHEMA, tabGen.schema() );
      }
      //FIXME implements uniqueconstrains

      if ( !BinderHelper.isDefault( tabGen.pkColumnName() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.PK_COLUMN_NAME, tabGen.pkColumnName() );
      }
      if ( !BinderHelper.isDefault( tabGen.valueColumnName() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.VALUE_COLUMN_NAME, tabGen.valueColumnName() );
      }
      if ( !BinderHelper.isDefault( tabGen.pkColumnValue() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.PK_VALUE_NAME, tabGen.pkColumnValue() );
      }
      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() );
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

      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );
      log.debug( "Add sequence generator with name: " + idGen.getName() );
    }
    if ( pckg.isAnnotationPresent( TableGenerator.class ) ) {
      TableGenerator ann = pckg.getAnnotation( TableGenerator.class );
      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );

    }
    bindGenericGenerators(pckg, mappings);
View Full Code Here

    }
    if ( ann == null ) {
      idGen = null;
    }
    else if ( ann instanceof TableGenerator ) {
      TableGenerator tabGen = (TableGenerator) ann;
      idGen.setName( tabGen.name() );
      idGen.setIdentifierGeneratorStrategy( MultipleHiLoPerTableGenerator.class.getName() );

      if ( !BinderHelper.isDefault( tabGen.table() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.ID_TABLE, tabGen.table() );
      }
      if ( !BinderHelper.isDefault( tabGen.catalog() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.CATALOG, tabGen.catalog() );
      }
      if ( !BinderHelper.isDefault( tabGen.schema() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.SCHEMA, tabGen.schema() );
      }
      //FIXME implements uniqueconstrains

      if ( !BinderHelper.isDefault( tabGen.pkColumnName() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.PK_COLUMN_NAME, tabGen.pkColumnName() );
      }
      if ( !BinderHelper.isDefault( tabGen.valueColumnName() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.VALUE_COLUMN_NAME, tabGen.valueColumnName() );
      }
      if ( !BinderHelper.isDefault( tabGen.pkColumnValue() ) ) {
        idGen.addParam( MultipleHiLoPerTableGenerator.PK_VALUE_NAME, tabGen.pkColumnValue() );
      }
      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() );
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

    Element element = tree != null ? tree.element( annotationToXml.get( TableGenerator.class ) ) : null;
    if ( element != null ) {
      return buildTableGeneratorAnnotation( element, defaults );
    }
    else if ( defaults.canUseJavaAnnotations() && isJavaAnnotationPresent( TableGenerator.class ) ) {
      TableGenerator tableAnn = getJavaAnnotation( TableGenerator.class );
      if ( StringHelper.isNotEmpty( defaults.getSchema() )
          || StringHelper.isNotEmpty( defaults.getCatalog() ) ) {
        AnnotationDescriptor annotation = new AnnotationDescriptor( TableGenerator.class );
        annotation.setValue( "name", tableAnn.name() );
        annotation.setValue( "table", tableAnn.table() );
        annotation.setValue( "catalog", tableAnn.table() );
        if ( StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) )
            && StringHelper.isNotEmpty( defaults.getCatalog() ) ) {
          annotation.setValue( "catalog", defaults.getCatalog() );
        }
        annotation.setValue( "schema", tableAnn.table() );
        if ( StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) )
            && StringHelper.isNotEmpty( defaults.getSchema() ) ) {
          annotation.setValue( "catalog", defaults.getSchema() );
        }
        annotation.setValue( "pkColumnName", tableAnn.pkColumnName() );
        annotation.setValue( "valueColumnName", tableAnn.valueColumnName() );
        annotation.setValue( "pkColumnValue", tableAnn.pkColumnValue() );
        annotation.setValue( "initialValue", tableAnn.initialValue() );
        annotation.setValue( "allocationSize", tableAnn.allocationSize() );
        annotation.setValue( "uniqueConstraints", tableAnn.uniqueConstraints() );
        return AnnotationFactory.create( annotation );
      }
      else {
        return tableAnn;
      }
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

      if ( LOG.isTraceEnabled() ) {
        LOG.tracev( "Add sequence generator with name: {0}", idGen.getName() );
      }
    }
    if ( pckg.isAnnotationPresent( TableGenerator.class ) ) {
      TableGenerator ann = pckg.getAnnotation( TableGenerator.class );
      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );

    }
    bindGenericGenerators( pckg, mappings );
View Full Code Here

TOP

Related Classes of javax.persistence.TableGenerator

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.