Package javax.persistence

Examples of javax.persistence.TableGenerator


    public long getNextSequence(long hostId) {
        if (s_logger.isTraceEnabled()) {
            s_logger.trace("getNextSequence(), hostId: " + hostId);
        }

        TableGenerator tg = _tgs.get("host_req_sq");
        assert tg != null : "how can this be wrong!";

        return s_seqFetcher.getNextSequence(Long.class, tg, hostId);
    }
View Full Code Here


        void onEntity(
                JpaEntity entity,
                AnnotatedElement element,
                AnnotationProcessorStack context) {

            TableGenerator annotation = element.getAnnotation(TableGenerator.class);
            entity.setTableGenerator(new JpaTableGenerator(annotation));
        }
View Full Code Here

        void onEntityMap(
                JpaEntityMap entityMap,
                AnnotatedElement element,
                AnnotationProcessorStack context) {

            TableGenerator annotation = element.getAnnotation(TableGenerator.class);
            entityMap.getTableGenerators().add(new JpaTableGenerator(annotation));
        }
View Full Code Here

        void onEntity(
                JpaEntity entity,
                AnnotatedElement element,
                AnnotationProcessorStack context) {

            TableGenerator annotation = element.getAnnotation(TableGenerator.class);
            entity.setTableGenerator(new JpaTableGenerator(annotation));
        }
View Full Code Here

        void onEntityMap(
                JpaEntityMap entityMap,
                AnnotatedElement element,
                AnnotationProcessorStack context) {

            TableGenerator annotation = element.getAnnotation(TableGenerator.class);
            entityMap.getTableGenerators().add(new JpaTableGenerator(annotation));
        }
View Full Code Here

        void onEntity(
                JpaEntity entity,
                AnnotatedElement element,
                AnnotationProcessorStack context) {

            TableGenerator annotation = element.getAnnotation(TableGenerator.class);
            entity.setTableGenerator(new JpaTableGenerator(annotation));
        }
View Full Code Here

        void onEntityMap(
                JpaEntityMap entityMap,
                AnnotatedElement element,
                AnnotationProcessorStack context) {

            TableGenerator annotation = element.getAnnotation(TableGenerator.class);
            entityMap.getTableGenerators().add(new JpaTableGenerator(annotation));
        }
View Full Code Here

      IdGenerator idGen = buildIdGenerator( ann, mappings );
      mappings.addGenerator( idGen );
            LOG.trace("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

    final boolean useNewGeneratorMappings = mappings.useNewGeneratorMappings();
    if ( ann == null ) {
      idGen = null;
    }
    else if ( ann instanceof TableGenerator ) {
      TableGenerator tabGen = ( TableGenerator ) ann;
      idGen.setName( tabGen.name() );
      if ( useNewGeneratorMappings ) {
        idGen.setIdentifierGeneratorStrategy( org.hibernate.id.enhanced.TableGenerator.class.getName() );
        idGen.addParam( org.hibernate.id.enhanced.TableGenerator.CONFIG_PREFER_SEGMENT_PER_ENTITY, "true" );

        if ( !BinderHelper.isEmptyAnnotationValue( tabGen.catalog() ) ) {
          idGen.addParam( PersistentIdentifierGenerator.CATALOG, tabGen.catalog() );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( tabGen.schema() ) ) {
          idGen.addParam( PersistentIdentifierGenerator.SCHEMA, tabGen.schema() );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( tabGen.table() ) ) {
          idGen.addParam( org.hibernate.id.enhanced.TableGenerator.TABLE_PARAM, tabGen.table() );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( tabGen.pkColumnName() ) ) {
          idGen.addParam(
              org.hibernate.id.enhanced.TableGenerator.SEGMENT_COLUMN_PARAM, tabGen.pkColumnName()
          );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( tabGen.pkColumnValue() ) ) {
          idGen.addParam(
              org.hibernate.id.enhanced.TableGenerator.SEGMENT_VALUE_PARAM, tabGen.pkColumnValue()
          );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( tabGen.valueColumnName() ) ) {
          idGen.addParam(
              org.hibernate.id.enhanced.TableGenerator.VALUE_COLUMN_PARAM, tabGen.valueColumnName()
          );
        }
        idGen.addParam(
            org.hibernate.id.enhanced.TableGenerator.INCREMENT_PARAM,
            String.valueOf( tabGen.allocationSize() )
        );
        // See comment on HHH-4884 wrt initialValue.  Basically initialValue is really the stated value + 1
        idGen.addParam(
            org.hibernate.id.enhanced.TableGenerator.INITIAL_PARAM,
            String.valueOf( tabGen.initialValue() + 1 )
        );
                if (tabGen.uniqueConstraints() != null && tabGen.uniqueConstraints().length > 0) LOG.warn(tabGen.name());
      }
      else {
        idGen.setIdentifierGeneratorStrategy( MultipleHiLoPerTableGenerator.class.getName() );

        if ( !BinderHelper.isEmptyAnnotationValue( tabGen.table() ) ) {
          idGen.addParam( MultipleHiLoPerTableGenerator.ID_TABLE, tabGen.table() );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( tabGen.catalog() ) ) {
          idGen.addParam( PersistentIdentifierGenerator.CATALOG, tabGen.catalog() );
        }
        if ( !BinderHelper.isEmptyAnnotationValue( tabGen.schema() ) ) {
          idGen.addParam( PersistentIdentifierGenerator.SCHEMA, tabGen.schema() );
        }
        //FIXME implement uniqueconstrains
                if (tabGen.uniqueConstraints() != null && tabGen.uniqueConstraints().length > 0) LOG.ignoringTableGeneratorConstraints(tabGen.name());

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

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.