• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SequenceStyleGenerator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.hibernate.id.enhanced.SequenceStyleGenerator的典型用法代码示例。如果您正苦于以下问题:Java SequenceStyleGenerator类的具体用法?Java SequenceStyleGenerator怎么用?Java SequenceStyleGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SequenceStyleGenerator类属于org.hibernate.id.enhanced包,在下文中一共展示了SequenceStyleGenerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: bindSimpleValue

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
protected void bindSimpleValue(PersistentProperty grailsProp,
                               PersistentProperty parentProperty, SimpleValue simpleValue,
                               String path, PropertyConfig propertyConfig, String sessionFactoryBeanName) {
    setTypeForPropertyConfig(grailsProp, simpleValue, propertyConfig);
    final PropertyConfig mappedForm = (PropertyConfig) grailsProp.getMapping().getMappedForm();
    if (mappedForm.isDerived() && !(grailsProp instanceof TenantId)) {
        Formula formula = new Formula();
        formula.setFormula(propertyConfig.getFormula());
        simpleValue.addFormula(formula);
    } else {
        Table table = simpleValue.getTable();
        boolean hasConfig = propertyConfig != null;

        String generator = hasConfig ? propertyConfig.getGenerator() : null;
        if(generator != null) {
            simpleValue.setIdentifierGeneratorStrategy(generator);
            Properties params = propertyConfig.getTypeParams();
            if(params != null) {
                Properties generatorProps = new Properties();
                generatorProps.putAll(params);

                if(generatorProps.containsKey(SEQUENCE_KEY)) {
                    generatorProps.put(SequenceStyleGenerator.SEQUENCE_PARAM,  generatorProps.getProperty(SEQUENCE_KEY));
                }
                simpleValue.setIdentifierGeneratorProperties( generatorProps );
            }
        }

        // Add the column definitions for this value/property. Note that
        // not all custom mapped properties will have column definitions,
        // in which case we still need to create a Hibernate column for
        // this value.
        List<?> columnDefinitions = hasConfig ? propertyConfig.getColumns()
                : Arrays.asList(new Object[] { null });
        if (columnDefinitions.isEmpty()) {
            columnDefinitions = Arrays.asList(new Object[] { null });
        }

        for (Object columnDefinition : columnDefinitions) {
            ColumnConfig cc = (ColumnConfig) columnDefinition;
            Column column = new Column();

            // Check for explicitly mapped column name and SQL type.
            if (cc != null) {
                if (cc.getName() != null) {
                    column.setName(cc.getName());
                }
                if (cc.getSqlType() != null) {
                    column.setSqlType(cc.getSqlType());
                }
            }

            column.setValue(simpleValue);


            if (cc != null) {
                if (cc.getLength() != -1) {
                    column.setLength(cc.getLength());
                }
                if (cc.getPrecision() != -1) {
                    column.setPrecision(cc.getPrecision());
                }
                if (cc.getScale() != -1) {
                    column.setScale(cc.getScale());
                }
                if(!mappedForm.isUniqueWithinGroup()) {
                    column.setUnique(cc.isUnique());
                }
            }

            bindColumn(grailsProp, parentProperty, column, cc, path, table, sessionFactoryBeanName);

            if (table != null) {
                table.addColumn(column);
            }

            simpleValue.addColumn(column);
        }
    }
}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:81,代码来源:GrailsDomainBinder.java


示例2: testNormalBoundary

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
public void testNormalBoundary() {
	EntityPersister persister = sfi().getEntityPersister( Entity.class.getName() );
	assertClassAssignability( SequenceStyleGenerator.class, persister.getIdentifierGenerator().getClass() );
	SequenceStyleGenerator generator = ( SequenceStyleGenerator ) persister.getIdentifierGenerator();
	assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
	OptimizerFactory.PooledOptimizer optimizer = ( OptimizerFactory.PooledOptimizer ) generator.getOptimizer();

	int increment = optimizer.getIncrementSize();
	Entity[] entities = new Entity[ increment + 1 ];
	Session s = openSession();
	s.beginTransaction();
	for ( int i = 0; i < increment; i++ ) {
		entities[i] = new Entity( "" + ( i + 1 ) );
		s.save( entities[i] );
		assertEquals( 2, generator.getDatabaseStructure().getTimesAccessed() ); // initialization calls seq twice
		assertEquals( increment + 1, optimizer.getLastSourceValue() ); // initialization calls seq twice
		assertEquals( i + 1, optimizer.getLastValue() );
		assertEquals( increment + 1, optimizer.getLastSourceValue() );
	}
	// now force a "clock over"
	entities[ increment ] = new Entity( "" + increment );
	s.save( entities[ increment ] );
	assertEquals( 3, generator.getDatabaseStructure().getTimesAccessed() ); // initialization (2) + clock over
	assertEquals( ( increment * 2 ) + 1, optimizer.getLastSourceValue() ); // initialization (2) + clock over
	assertEquals( increment + 1, optimizer.getLastValue() );
	s.getTransaction().commit();

	s.beginTransaction();
	for ( int i = 0; i < entities.length; i++ ) {
		assertEquals( i + 1, entities[i].getId().intValue() );
		s.delete( entities[i] );
	}
	s.getTransaction().commit();
	s.close();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:36,代码来源:PooledSequenceTest.java


示例3: testNormalBoundary

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
public void testNormalBoundary() {
	EntityPersister persister = sfi().getEntityPersister( Entity.class.getName() );
	assertClassAssignability( SequenceStyleGenerator.class, persister.getIdentifierGenerator().getClass() );
	SequenceStyleGenerator generator = ( SequenceStyleGenerator ) persister.getIdentifierGenerator();

	int count = 5;
	Entity[] entities = new Entity[count];
	Session s = openSession();
	s.beginTransaction();
	for ( int i = 0; i < count; i++ ) {
		entities[i] = new Entity( "" + ( i + 1 ) );
		s.save( entities[i] );
		long expectedId = i + 1;
		assertEquals( expectedId, entities[i].getId().longValue() );
		assertEquals( expectedId, generator.getDatabaseStructure().getTimesAccessed() );
		assertEquals( expectedId, generator.getOptimizer().getLastSourceValue() );
	}
	s.getTransaction().commit();

	s.beginTransaction();
	for ( int i = 0; i < count; i++ ) {
		assertEquals( i + 1, entities[i].getId().intValue() );
		s.delete( entities[i] );
	}
	s.getTransaction().commit();
	s.close();

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:29,代码来源:BasicSequenceTest.java


示例4: testNormalBoundary

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
public void testNormalBoundary() {
	EntityPersister persister = sfi().getEntityPersister( Entity.class.getName() );
	assertClassAssignability( SequenceStyleGenerator.class, persister.getIdentifierGenerator().getClass() );
	SequenceStyleGenerator generator = ( SequenceStyleGenerator ) persister.getIdentifierGenerator();
	assertClassAssignability( OptimizerFactory.HiLoOptimizer.class, generator.getOptimizer().getClass() );
	OptimizerFactory.HiLoOptimizer optimizer = ( OptimizerFactory.HiLoOptimizer ) generator.getOptimizer();

	int increment = optimizer.getIncrementSize();
	Entity[] entities = new Entity[ increment + 1 ];
	Session s = openSession();
	s.beginTransaction();
	for ( int i = 0; i < increment; i++ ) {
		entities[i] = new Entity( "" + ( i + 1 ) );
		s.save( entities[i] );
		assertEquals( 1, generator.getDatabaseStructure().getTimesAccessed() ); // initialization
		assertEquals( 1, optimizer.getLastSourceValue() ); // initialization
		assertEquals( i + 1, optimizer.getLastValue() );
		assertEquals( increment + 1, optimizer.getHiValue() );
	}
	// now force a "clock over"
	entities[ increment ] = new Entity( "" + increment );
	s.save( entities[ increment ] );
	assertEquals( 2, generator.getDatabaseStructure().getTimesAccessed() ); // initialization
	assertEquals( 2, optimizer.getLastSourceValue() ); // initialization
	assertEquals( increment + 1, optimizer.getLastValue() );
	assertEquals( ( increment * 2 ) + 1, optimizer.getHiValue() );

	s.getTransaction().commit();

	s.beginTransaction();
	for ( int i = 0; i < entities.length; i++ ) {
		assertEquals( i + 1, entities[i].getId().intValue() );
		s.delete( entities[i] );
	}
	s.getTransaction().commit();
	s.close();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:38,代码来源:HiLoSequenceTest.java


示例5: testDefaultedSequenceBackedConfiguration

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
/**
 * Test all params defaulted with a dialect supporting sequences
 */
public void testDefaultedSequenceBackedConfiguration() {
	Dialect dialect = new SequenceDialect();
	Properties props = new Properties();
	SequenceStyleGenerator generator = new SequenceStyleGenerator();
	generator.configure( Hibernate.LONG, props, dialect );

	assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
	assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
	assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:14,代码来源:SequenceStyleConfigUnitTest.java


示例6: testDefaultedTableBackedConfiguration

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
/**
 * Test all params defaulted with a dialect which does not support sequences
 */
public void testDefaultedTableBackedConfiguration() {
	Dialect dialect = new TableDialect();
	Properties props = new Properties();
	SequenceStyleGenerator generator = new SequenceStyleGenerator();
	generator.configure( Hibernate.LONG, props, dialect );

	assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
	assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
	assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:14,代码来源:SequenceStyleConfigUnitTest.java


示例7: testDefaultOptimizerBasedOnIncrementBackedByTable

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
/**
 * Test default optimizer selection for table backed generators
 * based on the configured increment size.  Here we always prefer
 * pooled.
 */
public void testDefaultOptimizerBasedOnIncrementBackedByTable() {
	Properties props = new Properties();
	props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "10" );
	Dialect dialect = new TableDialect();
	SequenceStyleGenerator generator = new SequenceStyleGenerator();
	generator.configure( Hibernate.LONG, props, dialect );
	assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
	assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
	assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:16,代码来源:SequenceStyleConfigUnitTest.java


示例8: testForceTableUse

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
/**
 * Test forcing of table as backing strucuture with dialect supporting sequences
 */
public void testForceTableUse() {
	Dialect dialect = new SequenceDialect();
	Properties props = new Properties();
	props.setProperty( SequenceStyleGenerator.FORCE_TBL_PARAM, "true" );
	SequenceStyleGenerator generator = new SequenceStyleGenerator();
	generator.configure( Hibernate.LONG, props, dialect );
	assertClassAssignability( TableStructure.class, generator.getDatabaseStructure().getClass() );
	assertClassAssignability( OptimizerFactory.NoopOptimizer.class, generator.getOptimizer().getClass() );
	assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, generator.getDatabaseStructure().getName() );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:14,代码来源:SequenceStyleConfigUnitTest.java


示例9: getStrategies

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
@Override
public Map<String, Class<?>> getStrategies() {
	return ImmutableMap.<String, Class<?>> builder()
			// overriding default SequenceStyleGenerator; our SequenceStyleGenerator is configured to
			// always generate a sequence by table
			.put(SequenceStyleGenerator.class.getName(), PerTableSequenceStyleGenerator.class).build();
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:8,代码来源:PerTableSequenceStrategyProvider.java


示例10: manageSequenceGenerator

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
private void manageSequenceGenerator(Mappings mappings, Table tab,
                                      SimpleValue id, SequenceGenerator generator) {
    id.setIdentifierGeneratorStrategy
            ("enhanced-sequence");
    Properties params = new Properties();
    params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER,
                mappings.getObjectNameNormalizer());
    params.put(SequenceStyleGenerator.SEQUENCE_PARAM,
                quoteIdentifier(generator.getName()));
    params.setProperty(
            SequenceStyleGenerator.SCHEMA,
            quoteIdentifier(tab.getSchema()));
    id.setIdentifierGeneratorProperties(params);
    id.setNullValue(null);
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:16,代码来源:HibernateConfig.java


示例11: configure

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
@Override
public void configure(
        Type type, Properties params, ServiceRegistry serviceRegistry)
        throws MappingException {
    final JdbcEnvironment jdbcEnvironment =
            serviceRegistry.getService(JdbcEnvironment.class);
    final Dialect dialect = jdbcEnvironment.getDialect();

    final ConfigurationService configurationService =
            serviceRegistry.getService(ConfigurationService.class);
    String globalEntityIdentifierPrefix =
        configurationService.getSetting( "entity.identifier.prefix", String.class, "SEQ_" );

    sequencePrefix = ConfigurationHelper.getString(
            SEQUENCE_PREFIX,
            params,
            globalEntityIdentifierPrefix);

    final String sequencePerEntitySuffix = ConfigurationHelper.getString(
            SequenceStyleGenerator.CONFIG_SEQUENCE_PER_ENTITY_SUFFIX,
            params,
            SequenceStyleGenerator.DEF_SEQUENCE_SUFFIX);

    final String defaultSequenceName = ConfigurationHelper.getBoolean(
            SequenceStyleGenerator.CONFIG_PREFER_SEQUENCE_PER_ENTITY,
            params,
            false)
            ? params.getProperty(JPA_ENTITY_NAME) + sequencePerEntitySuffix
            : SequenceStyleGenerator.DEF_SEQUENCE_NAME;

    sequenceCallSyntax = dialect.getSequenceNextValString(
            ConfigurationHelper.getString(
                    SequenceStyleGenerator.SEQUENCE_PARAM,
                    params,
                    defaultSequenceName));
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:37,代码来源:StringSequenceIdentifier.java


示例12: manageSequenceGenerator

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
private void manageSequenceGenerator(Mappings mappings, Table tab,
                                      SimpleValue id, SequenceGenerator generator) {
    id.setIdentifierGeneratorStrategy
            ("enhanced-sequence");
    Properties params = new Properties();
    params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER,
                mappings.getObjectNameNormalizer());
    params.put(SequenceStyleGenerator.SEQUENCE_PARAM,
                escapeName(generator.getName()));
    params.setProperty(
            SequenceStyleGenerator.SCHEMA,
            escapeName(tab.getSchema()));
    id.setIdentifierGeneratorProperties(params);
    id.setNullValue(null);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:16,代码来源:HibernateConfig.java


示例13: generatorType

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
private static String generatorType(GenerationType generatorEnum, Mappings mappings) {
	boolean useNewGeneratorMappings = mappings.useNewGeneratorMappings();
	switch ( generatorEnum ) {
		case IDENTITY:
			return "identity";
		case AUTO:
			return useNewGeneratorMappings
					? org.hibernate.id.enhanced.SequenceStyleGenerator.class.getName()
					: "native";
		case TABLE:
			return useNewGeneratorMappings
					? org.hibernate.id.enhanced.TableGenerator.class.getName()
					: MultipleHiLoPerTableGenerator.class.getName();
		case SEQUENCE:
			return useNewGeneratorMappings
					? org.hibernate.id.enhanced.SequenceStyleGenerator.class.getName()
					: "seqhilo";
	}
	throw new AssertionFailure( "Unknown GeneratorType: " + generatorEnum );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AnnotationBinder.java


示例14: bindSequenceGenerator

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
private static void bindSequenceGenerator(MetadataImplementor metadata, AnnotationInstance generator) {
	String name = JandexHelper.getValue( generator, "name", String.class );
	Map<String, String> parameterMap = new HashMap<String, String>();
	addStringParameter( generator, "sequenceName", parameterMap, SequenceStyleGenerator.SEQUENCE_PARAM );
	boolean useNewIdentifierGenerators = metadata.getOptions().useNewIdentifierGenerators();
	String strategy = EnumConversionHelper.generationTypeToGeneratorStrategyName(
			GenerationType.SEQUENCE,
			useNewIdentifierGenerators
	);
	if ( useNewIdentifierGenerators ) {
		addStringParameter( generator, "catalog", parameterMap, PersistentIdentifierGenerator.CATALOG );
		addStringParameter( generator, "schema", parameterMap, PersistentIdentifierGenerator.SCHEMA );
		parameterMap.put(
				SequenceStyleGenerator.INCREMENT_PARAM,
				String.valueOf( JandexHelper.getValue( generator, "allocationSize", Integer.class ) )
		);
		parameterMap.put(
				SequenceStyleGenerator.INITIAL_PARAM,
				String.valueOf( JandexHelper.getValue( generator, "initialValue", Integer.class ) )
		);
	}
	else {
		if ( JandexHelper.getValue( generator, "initialValue", Integer.class ) != 1 ) {
			LOG.unsupportedInitialValue( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS );
		}
		parameterMap.put(
				SequenceHiLoGenerator.MAX_LO,
				String.valueOf( JandexHelper.getValue( generator, "allocationSize", Integer.class ) - 1 )
		);
	}
	metadata.addIdGenerator( new IdGenerator( name, strategy, parameterMap ) );
	LOG.tracef( "Add sequence generator with name: %s", name );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:IdGeneratorBinder.java


示例15: DefaultIdentifierGeneratorFactory

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
/**
 * Constructs a new DefaultIdentifierGeneratorFactory.
 */
public DefaultIdentifierGeneratorFactory() {
	register( "uuid2", UUIDGenerator.class );
	register( "guid", GUIDGenerator.class );			// can be done with UUIDGenerator + strategy
	register( "uuid", UUIDHexGenerator.class );			// "deprecated" for new use
	register( "uuid.hex", UUIDHexGenerator.class ); 	// uuid.hex is deprecated
	register( "hilo", TableHiLoGenerator.class );
	register( "assigned", Assigned.class );
	register( "identity", IdentityGenerator.class );
	register( "select", SelectGenerator.class );
	register( "sequence", SequenceGenerator.class );
	register( "seqhilo", SequenceHiLoGenerator.class );
	register( "increment", IncrementGenerator.class );
	register( "foreign", ForeignGenerator.class );
	register( "sequence-identity", SequenceIdentityGenerator.class );
	register( "enhanced-sequence", SequenceStyleGenerator.class );
	register( "enhanced-table", TableGenerator.class );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:DefaultIdentifierGeneratorFactory.java


示例16: SequenceIdentifierGeneratorStrategyProvider

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
/**
 * Simple constructor registering strategies.
 */
public SequenceIdentifierGeneratorStrategyProvider() {
	strategies.put("enhanced-sequence", OptimizedSequenceStyleGenerator.class);
	strategies.put(SequenceStyleGenerator.class.getName(), OptimizedSequenceStyleGenerator.class);
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:8,代码来源:SequenceIdentifierGeneratorStrategyProvider.java


示例17: testFactoryConfiguration

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
/**
 * Check strategy configuration.
 */
@Test
public void testFactoryConfiguration() throws InstantiationException, IllegalAccessException {
	Assert.assertEquals(OptimizedSequenceStyleGenerator.class,
			SequenceIdentifierGeneratorStrategyProvider.class.newInstance().getStrategies().get(SequenceStyleGenerator.class.getName()));
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:9,代码来源:SequenceIdentifierGeneratorStrategyProviderTest.java


示例18: bindSimpleId

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void bindSimpleId(PersistentProperty identifier, RootClass entity,
                            InFlightMetadataCollector mappings, Identity mappedId, String sessionFactoryBeanName) {

    Mapping mapping = getMapping(identifier.getOwner());
    boolean useSequence = mapping != null && mapping.isTablePerConcreteClass();

    // create the id value
    SimpleValue id = new SimpleValue(mappings, entity.getTable());
    // set identifier on entity

    Properties params = new Properties();
    entity.setIdentifier(id);

    if (mappedId == null) {
        // configure generator strategy
        id.setIdentifierGeneratorStrategy(useSequence ? "sequence-identity" : "native");
    } else {
        String generator = mappedId.getGenerator();
        if("native".equals(generator) && useSequence) {
            generator = "sequence-identity";
        }
        id.setIdentifierGeneratorStrategy(generator);
        params.putAll(mappedId.getParams());
        if(params.containsKey(SEQUENCE_KEY)) {
            params.put(SequenceStyleGenerator.SEQUENCE_PARAM,  params.getProperty(SEQUENCE_KEY));
        }
        if ("assigned".equals(generator)) {
            id.setNullValue("undefined");
        }
    }

    String schemaName = getSchemaName(mappings);
    String catalogName = getCatalogName(mappings);

    params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, this.metadataBuildingContext.getObjectNameNormalizer());

    if (schemaName != null) {
        params.setProperty(PersistentIdentifierGenerator.SCHEMA, schemaName);
    }
    if (catalogName != null) {
        params.setProperty(PersistentIdentifierGenerator.CATALOG, catalogName);
    }
    id.setIdentifierGeneratorProperties(params);

    // bind value
    bindSimpleValue(identifier, null, id, EMPTY_PATH, mappings, sessionFactoryBeanName);

    // create property
    Property prop = new Property();
    prop.setValue(id);

    // bind property
    bindProperty(identifier, prop, mappings);
    // set identifier property
    entity.setIdentifierProperty(prop);

    id.getTable().setIdentifierValue(id);
}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:60,代码来源:GrailsDomainBinder.java


示例19: enableOneSequencePerEntity

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
@Around("execution(* org.hibernate.id.enhanced.SequenceStyleGenerator.configure(..))")
public Object enableOneSequencePerEntity(final ProceedingJoinPoint pjp) throws Throwable {
    final Properties properties = (Properties) pjp.getArgs()[1];
    properties.put(SequenceStyleGenerator.CONFIG_PREFER_SEQUENCE_PER_ENTITY, true);
    return pjp.proceed();
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:7,代码来源:OneSequencePerEntityAspect.java


示例20: testAspectWorking

import org.hibernate.id.enhanced.SequenceStyleGenerator; //导入依赖的package包/类
@Test
public void testAspectWorking() {
    final Type type = null;
    final Properties params = new Properties();
    final ServiceRegistry serviceRegistry = null;
    try {
        new SequenceStyleGenerator().configure(type, params, serviceRegistry);
        Assertions.fail("exception expected");
    } catch (final NullPointerException e) { //SUPPRESS CHECKSTYLE single line
        //ignore
    }

    Assertions.assertThat(params.get(SequenceStyleGenerator.CONFIG_PREFER_SEQUENCE_PER_ENTITY)).isEqualTo(true);
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:15,代码来源:OneSequencePerEntityAspectTest.java



注:本文中的org.hibernate.id.enhanced.SequenceStyleGenerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SQLUtils类代码示例发布时间:2022-05-22
下一篇:
Java DataEditorSupport类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap