Search in sources :

Example 1 with KeyValue

use of org.hibernate.mapping.KeyValue in project hibernate-orm by hibernate.

the class IdentityGeneratorExtendsTest method testIdentifierGeneratorExtendsIdentityGenerator.

@Test
public void testIdentifierGeneratorExtendsIdentityGenerator() {
    final MetadataSources sources = new MetadataSources(serviceRegistry());
    sources.addAnnotatedClass(EntityBean.class);
    final MetadataBuilder builder = sources.getMetadataBuilder();
    final Metadata metadata = builder.build();
    for (final Namespace ns : metadata.getDatabase().getNamespaces()) {
        for (final org.hibernate.mapping.Table table : ns.getTables()) {
            final KeyValue value = table.getIdentifierValue();
            assertNotNull("IdentifierValue was null", value);
            assertTrue(value.isIdentityColumn(metadata.getIdentifierGeneratorFactory(), getDialect()));
        }
    }
    Session s = openSession();
    s.beginTransaction();
    s.save(new EntityBean());
    s.getTransaction().commit();
    s.close();
}
Also used : KeyValue(org.hibernate.mapping.KeyValue) MetadataBuilder(org.hibernate.boot.MetadataBuilder) MetadataSources(org.hibernate.boot.MetadataSources) Metadata(org.hibernate.boot.Metadata) Namespace(org.hibernate.boot.model.relational.Namespace) Session(org.hibernate.Session) Test(org.junit.Test)

Example 2 with KeyValue

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

the class ValueFacadeTest method testGetKey.

@Test
public void testGetKey() {
    Map valueTarget = new Map(null, null);
    valueFacade = FACADE_FACTORY.createValue(valueTarget);
    Assert.assertNull(valueFacade.getKey());
    KeyValue keyValue = new SimpleValue(null);
    valueTarget.setKey(keyValue);
    Assert.assertSame(keyValue, ((IFacade) valueFacade.getKey()).getTarget());
}
Also used : KeyValue(org.hibernate.mapping.KeyValue) Map(org.hibernate.mapping.Map) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 3 with KeyValue

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

the class ValueFacadeTest method testSetKey.

@Test
public void testSetKey() {
    KeyValue keyValueTarget = new SimpleValue(null);
    IValue keyValueFacade = FACADE_FACTORY.createValue(keyValueTarget);
    Collection collectionTarget = new Bag(null, null);
    IValue collectionFacade = FACADE_FACTORY.createValue(collectionTarget);
    Assert.assertNull(collectionTarget.getKey());
    collectionFacade.setKey(keyValueFacade);
    Assert.assertSame(keyValueTarget, collectionTarget.getKey());
}
Also used : KeyValue(org.hibernate.mapping.KeyValue) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) Collection(org.hibernate.mapping.Collection) Bag(org.hibernate.mapping.Bag) IdentifierBag(org.hibernate.mapping.IdentifierBag) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 4 with KeyValue

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

the class TableFacadeTest method testGetIdentifierValue.

@Test
public void testGetIdentifierValue() {
    Table table = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(table);
    IValue valueFacade = tableFacade.getIdentifierValue();
    Assert.assertNull(valueFacade);
    KeyValue value = new SimpleValue(null);
    table.setIdentifierValue(value);
    valueFacade = tableFacade.getIdentifierValue();
    Assert.assertSame(value, ((IFacade) valueFacade).getTarget());
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) KeyValue(org.hibernate.mapping.KeyValue) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 5 with KeyValue

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

the class TableFacadeTest method testGetIdentifierValue.

@Test
public void testGetIdentifierValue() {
    Table table = new Table();
    ITable tableFacade = FACADE_FACTORY.createTable(table);
    IValue valueFacade = tableFacade.getIdentifierValue();
    Assert.assertNull(valueFacade);
    KeyValue value = new SimpleValue(null);
    table.setIdentifierValue(value);
    valueFacade = tableFacade.getIdentifierValue();
    Assert.assertSame(value, ((IFacade) valueFacade).getTarget());
}
Also used : Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) KeyValue(org.hibernate.mapping.KeyValue) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Aggregations

KeyValue (org.hibernate.mapping.KeyValue)30 Test (org.junit.Test)25 SimpleValue (org.hibernate.mapping.SimpleValue)24 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)16 Collection (org.hibernate.mapping.Collection)9 Bag (org.hibernate.mapping.Bag)8 IdentifierBag (org.hibernate.mapping.IdentifierBag)8 Map (org.hibernate.mapping.Map)8 Table (org.hibernate.mapping.Table)8 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)8 Iterator (java.util.Iterator)3 JoinColumn (javax.persistence.JoinColumn)2 Ejb3JoinColumn (org.hibernate.cfg.Ejb3JoinColumn)2 Property (org.hibernate.mapping.Property)2 ArrayList (java.util.ArrayList)1 CollectionTable (javax.persistence.CollectionTable)1 ConstraintMode (javax.persistence.ConstraintMode)1 ElementCollection (javax.persistence.ElementCollection)1 JoinTable (javax.persistence.JoinTable)1 MapKeyColumn (javax.persistence.MapKeyColumn)1