use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class ListMappingTest method testOrderColumnInNormalBiDirectonalModel.
@Test
public void testOrderColumnInNormalBiDirectonalModel() {
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Order.class).addAnnotatedClass(LineItem.class).buildMetadata();
Collection lineItemsBinding = metadata.getCollectionBindings().iterator().next();
// make sure it was interpreted as a List (aka, as having an OrderColumn at all)
assertThat(lineItemsBinding, instanceOf(org.hibernate.mapping.List.class));
org.hibernate.mapping.List asList = (org.hibernate.mapping.List) lineItemsBinding;
// assert the OrderColumn details
final Column positionColumn = (Column) asList.getIndex().getColumnIterator().next();
assertThat(positionColumn.getName(), equalTo("position"));
// make sure the OrderColumn is part of the collection table
assertTrue(asList.getCollectionTable().containsColumn(positionColumn));
class TargetImpl extends GenerationTargetToStdout {
boolean found = false;
@Override
public void accept(String action) {
super.accept(action);
if (action.startsWith("create table t_line_item")) {
if (action.contains("position")) {
found = true;
}
}
}
}
TargetImpl target = new TargetImpl();
new SchemaCreatorImpl(ssr).doCreation(metadata, true, target);
assertTrue(target.found);
}
use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class SortTest method testSortedSetDefinitionInHbmXml.
@Test
public void testSortedSetDefinitionInHbmXml() {
final PersistentClass entityMapping = metadata().getEntityBinding(Search.class.getName());
final Property sortedSetProperty = entityMapping.getProperty("searchResults");
final Collection sortedSetMapping = assertTyping(Collection.class, sortedSetProperty.getValue());
assertTrue("SortedSet mapping not interpreted as sortable", sortedSetMapping.isSorted());
final Property sortedMapProperty = entityMapping.getProperty("tokens");
final Collection sortedMapMapping = assertTyping(Collection.class, sortedMapProperty.getValue());
assertTrue("SortedMap mapping not interpreted as sortable", sortedMapMapping.isSorted());
}
Aggregations