Search in sources :

Example 21 with BasicValue

use of org.hibernate.mapping.BasicValue in project jbosstools-hibernate by jbosstools.

the class ValueFacadeTest method testSetTypeName.

@Test
public void testSetTypeName() {
    SimpleValue valueTarget = new BasicValue(DummyMetadataBuildingContext.INSTANCE);
    valueFacade = new AbstractValueFacade(FACADE_FACTORY, valueTarget) {
    };
    assertNull(valueTarget.getTypeName());
    valueFacade.setTypeName("java.lang.Integer");
    assertEquals("java.lang.Integer", valueTarget.getTypeName());
}
Also used : AbstractValueFacade(org.jboss.tools.hibernate.runtime.common.AbstractValueFacade) SimpleValue(org.hibernate.mapping.SimpleValue) BasicValue(org.hibernate.mapping.BasicValue) Test(org.junit.jupiter.api.Test)

Example 22 with BasicValue

use of org.hibernate.mapping.BasicValue in project jbosstools-hibernate by jbosstools.

the class ClassMetadataFacadeTest method createPersistentClass.

private PersistentClass createPersistentClass(MetadataBuildingContext metadataBuildingContext) {
    RootClass rc = new RootClass(metadataBuildingContext);
    Table t = new Table("tools", "foobar");
    rc.setTable(t);
    Column c = new Column("foo");
    t.addColumn(c);
    ArrayList<Column> keyList = new ArrayList<>();
    keyList.add(c);
    t.createUniqueKey(keyList);
    BasicValue sv = new BasicValue(metadataBuildingContext, t);
    sv.setNullValue("null");
    sv.setTypeName(Integer.class.getName());
    sv.addColumn(c);
    rc.setEntityName("foobar");
    rc.setIdentifier(sv);
    rc.setClassName(FooBar.class.getName());
    rc.setOptimisticLockStyle(OptimisticLockStyle.NONE);
    return rc;
}
Also used : RootClass(org.hibernate.mapping.RootClass) Table(org.hibernate.mapping.Table) Column(org.hibernate.mapping.Column) ArrayList(java.util.ArrayList) BasicValue(org.hibernate.mapping.BasicValue)

Example 23 with BasicValue

use of org.hibernate.mapping.BasicValue in project jbosstools-hibernate by jbosstools.

the class Cfg2HbmToolFacadeTest method testGetTagProperty.

@Test
public void testGetTagProperty() throws Exception {
    RootClass rc = new RootClass(DummyMetadataBuildingContext.INSTANCE);
    Property p = new Property();
    BasicValue basicValue = new BasicValue(DummyMetadataBuildingContext.INSTANCE);
    basicValue.setTypeName("foobar");
    p.setValue(basicValue);
    p.setPersistentClass(rc);
    rc.setVersion(p);
    IProperty property = new AbstractPropertyFacade(FACADE_FACTORY, p) {
    };
    assertEquals("version", cfg2HbmToolFacade.getTag(property));
}
Also used : RootClass(org.hibernate.mapping.RootClass) AbstractPropertyFacade(org.jboss.tools.hibernate.runtime.common.AbstractPropertyFacade) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) Property(org.hibernate.mapping.Property) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) BasicValue(org.hibernate.mapping.BasicValue) Test(org.junit.jupiter.api.Test)

Example 24 with BasicValue

use of org.hibernate.mapping.BasicValue in project jbosstools-hibernate by jbosstools.

the class ColumnFacadeTest method testGetSqlType.

@Test
public void testGetSqlType() {
    assertNull(columnFacade.getSqlType());
    column.setSqlType("foobar");
    assertEquals("foobar", columnFacade.getSqlType());
    Configuration configuration = new Configuration();
    configuration.setProperty(AvailableSettings.DIALECT, MockDialect.class.getName());
    configuration.setProperty(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
    BasicValue value = new BasicValue(createMetadataBuildingContext());
    value.setTypeName("int");
    column.setValue(value);
    IConfiguration configurationFacade = FACADE_FACTORY.createConfiguration(configuration);
    column.setSqlType(null);
    assertEquals("integer", columnFacade.getSqlType(configurationFacade));
}
Also used : MockConnectionProvider(org.jboss.tools.hibernate.runtime.v_6_0.internal.util.MockConnectionProvider) Configuration(org.hibernate.cfg.Configuration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) MockDialect(org.jboss.tools.hibernate.runtime.v_6_0.internal.util.MockDialect) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) BasicValue(org.hibernate.mapping.BasicValue) Test(org.junit.jupiter.api.Test)

Example 25 with BasicValue

use of org.hibernate.mapping.BasicValue in project jbosstools-hibernate by jbosstools.

the class ValueFacadeTest method testGetIndex.

@Test
public void testGetIndex() {
    List valueTarget = new List(DummyMetadataBuildingContext.INSTANCE, null);
    valueFacade = new AbstractValueFacade(FACADE_FACTORY, valueTarget) {
    };
    assertNull(valueFacade.getIndex());
    SimpleValue indexValue = new BasicValue(DummyMetadataBuildingContext.INSTANCE);
    valueTarget.setIndex(indexValue);
    assertSame(indexValue, ((IFacade) valueFacade.getIndex()).getTarget());
}
Also used : AbstractValueFacade(org.jboss.tools.hibernate.runtime.common.AbstractValueFacade) List(org.hibernate.mapping.List) SimpleValue(org.hibernate.mapping.SimpleValue) BasicValue(org.hibernate.mapping.BasicValue) Test(org.junit.jupiter.api.Test)

Aggregations

BasicValue (org.hibernate.mapping.BasicValue)40 Test (org.junit.jupiter.api.Test)39 AbstractValueFacade (org.jboss.tools.hibernate.runtime.common.AbstractValueFacade)36 SimpleValue (org.hibernate.mapping.SimpleValue)22 RootClass (org.hibernate.mapping.RootClass)7 Table (org.hibernate.mapping.Table)6 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)6 IdentifierBag (org.hibernate.mapping.IdentifierBag)5 Set (org.hibernate.mapping.Set)5 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)5 Bag (org.hibernate.mapping.Bag)4 Column (org.hibernate.mapping.Column)3 KeyValue (org.hibernate.mapping.KeyValue)3 List (org.hibernate.mapping.List)3 ManyToOne (org.hibernate.mapping.ManyToOne)3 OneToOne (org.hibernate.mapping.OneToOne)3 Collection (org.hibernate.mapping.Collection)2 Component (org.hibernate.mapping.Component)2 Map (org.hibernate.mapping.Map)2 PrimitiveArray (org.hibernate.mapping.PrimitiveArray)2