Search in sources :

Example 1 with MetadataBuildingContextTestingImpl

use of org.hibernate.testing.boot.MetadataBuildingContextTestingImpl in project hibernate-orm by hibernate.

the class SequenceHiLoGeneratorNoIncrementTest method setUp.

@Before
public void setUp() throws Exception {
    serviceRegistry = new StandardServiceRegistryBuilder().enableAutoClose().applySetting(AvailableSettings.HBM2DDL_AUTO, "create-drop").build();
    generator = new SequenceStyleGenerator();
    // Build the properties used to configure the id generator
    Properties properties = new Properties();
    properties.setProperty(SequenceStyleGenerator.SEQUENCE_PARAM, TEST_SEQUENCE);
    properties.setProperty(SequenceStyleGenerator.OPT_PARAM, "legacy-hilo");
    // JPA allocationSize of 1
    properties.setProperty(SequenceStyleGenerator.INCREMENT_PARAM, "0");
    properties.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, new ObjectNameNormalizer() {

        @Override
        protected MetadataBuildingContext getBuildingContext() {
            return new MetadataBuildingContextTestingImpl(serviceRegistry);
        }
    });
    generator.configure(StandardBasicTypes.LONG, properties, serviceRegistry);
    final Metadata metadata = new MetadataSources(serviceRegistry).buildMetadata();
    generator.registerExportables(metadata.getDatabase());
    sessionFactory = (SessionFactoryImplementor) metadata.buildSessionFactory();
    sequenceValueExtractor = new SequenceValueExtractor(sessionFactory.getDialect(), TEST_SEQUENCE);
}
Also used : MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) MetadataBuildingContext(org.hibernate.boot.spi.MetadataBuildingContext) ObjectNameNormalizer(org.hibernate.boot.model.naming.ObjectNameNormalizer) SequenceStyleGenerator(org.hibernate.id.enhanced.SequenceStyleGenerator) Properties(java.util.Properties) Before(org.junit.Before)

Example 2 with MetadataBuildingContextTestingImpl

use of org.hibernate.testing.boot.MetadataBuildingContextTestingImpl in project hibernate-orm by hibernate.

the class SequenceHiLoGeneratorTest method setUp.

@Before
public void setUp() throws Exception {
    serviceRegistry = new StandardServiceRegistryBuilder().enableAutoClose().applySetting(AvailableSettings.HBM2DDL_AUTO, "create-drop").build();
    MetadataBuildingContext buildingContext = new MetadataBuildingContextTestingImpl(serviceRegistry);
    Properties properties = new Properties();
    properties.setProperty(SequenceGenerator.SEQUENCE, TEST_SEQUENCE);
    properties.setProperty(SequenceHiLoGenerator.MAX_LO, "3");
    properties.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, buildingContext.getObjectNameNormalizer());
    generator = new SequenceHiLoGenerator();
    generator.configure(StandardBasicTypes.LONG, properties, serviceRegistry);
    Metadata metadata = new MetadataSources(serviceRegistry).buildMetadata();
    generator.registerExportables(metadata.getDatabase());
    sessionFactory = (SessionFactoryImplementor) metadata.buildSessionFactory();
    sequenceValueExtractor = new SequenceValueExtractor(sessionFactory.getDialect(), TEST_SEQUENCE);
}
Also used : MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) MetadataBuildingContext(org.hibernate.boot.spi.MetadataBuildingContext) Properties(java.util.Properties) Before(org.junit.Before)

Example 3 with MetadataBuildingContextTestingImpl

use of org.hibernate.testing.boot.MetadataBuildingContextTestingImpl in project hibernate-orm by hibernate.

the class SequenceStyleConfigUnitTest method buildGeneratorPropertiesBase.

private Properties buildGeneratorPropertiesBase(StandardServiceRegistry serviceRegistry) {
    Properties props = new Properties();
    props.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, new MetadataBuildingContextTestingImpl(serviceRegistry).getObjectNameNormalizer());
    return props;
}
Also used : MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) Properties(java.util.Properties)

Example 4 with MetadataBuildingContextTestingImpl

use of org.hibernate.testing.boot.MetadataBuildingContextTestingImpl in project hibernate-orm by hibernate.

the class PersistentClassVisitorTest method prepare.

@Before
public void prepare() {
    serviceRegistry = new StandardServiceRegistryBuilder().build();
    metadataBuildingContext = new MetadataBuildingContextTestingImpl(serviceRegistry);
}
Also used : MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Before(org.junit.Before)

Example 5 with MetadataBuildingContextTestingImpl

use of org.hibernate.testing.boot.MetadataBuildingContextTestingImpl in project hibernate-orm by hibernate.

the class ValueVisitorTest method prepare.

@Before
public void prepare() {
    serviceRegistry = new StandardServiceRegistryBuilder().build();
    metadataBuildingContext = new MetadataBuildingContextTestingImpl(serviceRegistry);
}
Also used : MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Before(org.junit.Before)

Aggregations

MetadataBuildingContextTestingImpl (org.hibernate.testing.boot.MetadataBuildingContextTestingImpl)8 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)5 Before (org.junit.Before)5 Properties (java.util.Properties)3 MetadataSources (org.hibernate.boot.MetadataSources)3 Metadata (org.hibernate.boot.Metadata)2 MetadataBuildingContext (org.hibernate.boot.spi.MetadataBuildingContext)2 SimpleValue (org.hibernate.mapping.SimpleValue)2 Test (org.junit.Test)2 IrrelevantEntity (org.hibernate.IrrelevantEntity)1 ClassmateContext (org.hibernate.boot.internal.ClassmateContext)1 InstanceBasedConverterDescriptor (org.hibernate.boot.model.convert.internal.InstanceBasedConverterDescriptor)1 ObjectNameNormalizer (org.hibernate.boot.model.naming.ObjectNameNormalizer)1 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)1 SequenceStyleGenerator (org.hibernate.id.enhanced.SequenceStyleGenerator)1 Any (org.hibernate.mapping.Any)1 Array (org.hibernate.mapping.Array)1 Bag (org.hibernate.mapping.Bag)1 Component (org.hibernate.mapping.Component)1 DependantValue (org.hibernate.mapping.DependantValue)1