Search in sources :

Example 6 with Bag

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

the class AbstractJPAIndexTest method testJoinTableIndex.

@Test
public void testJoinTableIndex() {
    PersistentClass entity = metadata().getEntityBinding(Importer.class.getName());
    Property property = entity.getProperty("cars");
    Bag set = (Bag) property.getValue();
    Table collectionTable = set.getCollectionTable();
    Iterator<Index> itr = collectionTable.getIndexIterator();
    assertTrue(itr.hasNext());
    Index index = itr.next();
    assertFalse(itr.hasNext());
    assertTrue("index name is not generated", StringHelper.isNotEmpty(index.getName()));
    assertEquals(1, index.getColumnSpan());
    Iterator<Column> columnIterator = index.getColumnIterator();
    Column column = columnIterator.next();
    assertEquals("importers_id", column.getName());
    assertSame(collectionTable, index.getTable());
}
Also used : Table(org.hibernate.mapping.Table) Column(org.hibernate.mapping.Column) Bag(org.hibernate.mapping.Bag) Index(org.hibernate.mapping.Index) Property(org.hibernate.mapping.Property) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Aggregations

Bag (org.hibernate.mapping.Bag)6 Property (org.hibernate.mapping.Property)5 Test (org.junit.Test)5 PersistentClass (org.hibernate.mapping.PersistentClass)4 MetadataSources (org.hibernate.boot.MetadataSources)3 Column (org.hibernate.mapping.Column)3 SimpleValue (org.hibernate.mapping.SimpleValue)3 Metadata (org.hibernate.boot.Metadata)2 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)2 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)2 Array (org.hibernate.mapping.Array)2 Component (org.hibernate.mapping.Component)2 IdentifierBag (org.hibernate.mapping.IdentifierBag)2 PrimitiveArray (org.hibernate.mapping.PrimitiveArray)2 Set (org.hibernate.mapping.Set)2 Table (org.hibernate.mapping.Table)2 TestForIssue (org.hibernate.testing.TestForIssue)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1