Search in sources :

Example 6 with MetadataBuildingContextTestingImpl

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

the class AttributeConverterTest method testBasicOperation.

@Test
public void testBasicOperation() {
    SimpleValue simpleValue = new SimpleValue(new MetadataBuildingContextTestingImpl());
    simpleValue.setJpaAttributeConverterDescriptor(new InstanceBasedConverterDescriptor(new StringClobConverter(), new ClassmateContext()));
    simpleValue.setTypeUsingReflection(IrrelevantEntity.class.getName(), "name");
    Type type = simpleValue.getType();
    assertNotNull(type);
    if (!AttributeConverterTypeAdapter.class.isInstance(type)) {
        fail("AttributeConverter not applied");
    }
    AbstractStandardBasicType basicType = assertTyping(AbstractStandardBasicType.class, type);
    assertSame(StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor());
    assertEquals(Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType());
}
Also used : MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) BasicType(org.hibernate.type.BasicType) AbstractStandardBasicType(org.hibernate.type.AbstractStandardBasicType) Type(org.hibernate.type.Type) IrrelevantEntity(org.hibernate.IrrelevantEntity) AttributeConverterTypeAdapter(org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter) InstanceBasedConverterDescriptor(org.hibernate.boot.model.convert.internal.InstanceBasedConverterDescriptor) AbstractStandardBasicType(org.hibernate.type.AbstractStandardBasicType) SimpleValue(org.hibernate.mapping.SimpleValue) ClassmateContext(org.hibernate.boot.internal.ClassmateContext) Test(org.junit.Test)

Example 7 with MetadataBuildingContextTestingImpl

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

the class ValueVisitorTest method testProperCallbacks.

@Test
public void testProperCallbacks() {
    final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(serviceRegistry).buildMetadata();
    final Table tbl = new Table();
    final RootClass rootClass = new RootClass(metadataBuildingContext);
    ValueVisitor vv = new ValueVisitorValidator();
    MetadataBuildingContextTestingImpl metadataBuildingContext = new MetadataBuildingContextTestingImpl();
    new Any(metadataBuildingContext, tbl).accept(vv);
    new Array(metadataBuildingContext, rootClass).accept(vv);
    new Bag(metadataBuildingContext, rootClass).accept(vv);
    new Component(metadataBuildingContext, rootClass).accept(vv);
    new DependantValue(metadataBuildingContext, tbl, null).accept(vv);
    new IdentifierBag(metadataBuildingContext, rootClass).accept(vv);
    new List(metadataBuildingContext, rootClass).accept(vv);
    new ManyToOne(metadataBuildingContext, tbl).accept(vv);
    new Map(metadataBuildingContext, rootClass).accept(vv);
    new OneToMany(metadataBuildingContext, rootClass).accept(vv);
    new OneToOne(metadataBuildingContext, tbl, rootClass).accept(vv);
    new PrimitiveArray(metadataBuildingContext, rootClass).accept(vv);
    new Set(metadataBuildingContext, rootClass).accept(vv);
    new SimpleValue(metadataBuildingContext).accept(vv);
}
Also used : RootClass(org.hibernate.mapping.RootClass) Table(org.hibernate.mapping.Table) Set(org.hibernate.mapping.Set) ValueVisitor(org.hibernate.mapping.ValueVisitor) DependantValue(org.hibernate.mapping.DependantValue) MetadataSources(org.hibernate.boot.MetadataSources) Bag(org.hibernate.mapping.Bag) IdentifierBag(org.hibernate.mapping.IdentifierBag) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) IdentifierBag(org.hibernate.mapping.IdentifierBag) OneToMany(org.hibernate.mapping.OneToMany) Any(org.hibernate.mapping.Any) ManyToOne(org.hibernate.mapping.ManyToOne) SimpleValue(org.hibernate.mapping.SimpleValue) MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) Array(org.hibernate.mapping.Array) PrimitiveArray(org.hibernate.mapping.PrimitiveArray) OneToOne(org.hibernate.mapping.OneToOne) PrimitiveArray(org.hibernate.mapping.PrimitiveArray) List(org.hibernate.mapping.List) Component(org.hibernate.mapping.Component) Map(org.hibernate.mapping.Map) Test(org.junit.Test)

Example 8 with MetadataBuildingContextTestingImpl

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

the class PersistentClassTest 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