use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class SubselectFetchWithFormulaTest method checkSubselectWithFormula.
@Test
public void checkSubselectWithFormula() throws Exception {
// as a pre-condition make sure that subselect fetching is enabled for the collection...
Collection collectionBinding = metadata().getCollectionBinding(Name.class.getName() + ".values");
assertThat(collectionBinding.isSubselectLoadable(), is(true));
// Now force the subselect fetch and make sure we do not get SQL errors
Session session = openSession();
session.getTransaction().begin();
List results = session.createCriteria(Name.class).list();
for (Object result : results) {
Name name = (Name) result;
name.getValues().size();
}
session.getTransaction().commit();
session.close();
}
use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class SubselectFetchWithFormulaTransactSqlTest method checkSubselectWithFormula.
@Test
public void checkSubselectWithFormula() throws Exception {
// as a pre-condition make sure that subselect fetching is enabled for the collection...
Collection collectionBinding = metadata().getCollectionBinding(Name.class.getName() + ".values");
assertThat(collectionBinding.isSubselectLoadable(), is(true));
// Now force the subselect fetch and make sure we do not get SQL errors
Session session = openSession();
session.getTransaction().begin();
List results = session.createCriteria(Name.class).list();
for (Object result : results) {
Name name = (Name) result;
name.getValues().size();
}
session.getTransaction().commit();
session.close();
}
use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class IndexedCollectionTest method isDefaultColumnPresent.
private boolean isDefaultColumnPresent(String collectionOwner, String propertyName, String suffix) {
final Collection collection = metadata().getCollectionBinding(collectionOwner + "." + propertyName);
final Iterator columnIterator = collection.getCollectionTable().getColumnIterator();
boolean hasDefault = false;
while (columnIterator.hasNext()) {
Column column = (Column) columnIterator.next();
if ((propertyName + suffix).equals(column.getName()))
hasDefault = true;
}
return hasDefault;
}
use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class NonReflectiveBinderTest method testComparator.
@Test
public void testComparator() {
PersistentClass cm = metadata.getEntityBinding("org.hibernate.test.legacy.Wicked");
Property property = cm.getProperty("sortedEmployee");
Collection col = (Collection) property.getValue();
assertEquals(col.getComparatorClassName(), "org.hibernate.test.legacy.NonExistingComparator");
}
use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class DefaultNamingCollectionElementTest method isCollectionColumnPresent.
private void isCollectionColumnPresent(String collectionOwner, String propertyName, String columnName) {
final Collection collection = metadata().getCollectionBinding(collectionOwner + "." + propertyName);
final Iterator columnIterator = collection.getCollectionTable().getColumnIterator();
boolean hasDefault = false;
while (columnIterator.hasNext()) {
Column column = (Column) columnIterator.next();
if (columnName.equals(column.getName()))
hasDefault = true;
}
assertTrue("Could not find " + columnName, hasDefault);
}
Aggregations