use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class BaseNamingTests method validateCustomerRegisteredTrademarks.
protected void validateCustomerRegisteredTrademarks(Metadata metadata) {
final Collection collectionBinding = metadata.getCollectionBinding(Customer.class.getName() + ".registeredTrademarks");
assertNotNull(collectionBinding);
validateCustomerRegisteredTrademarksTableName(collectionBinding.getCollectionTable().getQuotedName());
assertEquals(1, collectionBinding.getKey().getColumnSpan());
validateCustomerRegisteredTrademarksKeyColumn((Column) collectionBinding.getKey().getColumnIterator().next());
assertEquals(1, collectionBinding.getElement().getColumnSpan());
validateCustomerRegisteredTrademarksElementColumn((Column) collectionBinding.getElement().getColumnIterator().next());
}
use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class BaseNamingTests method validateCustomerAddresses.
protected void validateCustomerAddresses(Metadata metadata) {
final Collection collectionBinding = metadata.getCollectionBinding(Customer.class.getName() + ".addresses");
assertNotNull(collectionBinding);
validateCustomerAddressesTableName(collectionBinding.getCollectionTable().getQuotedName());
assertEquals(1, collectionBinding.getKey().getColumnSpan());
validateCustomerAddressesKeyColumn((Column) collectionBinding.getKey().getColumnIterator().next());
assertEquals(3, collectionBinding.getElement().getColumnSpan());
validateCustomerAddressesElementComponent(assertTyping(Component.class, collectionBinding.getElement()));
}
use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class BaseNamingTests method validateCustomerOrders.
protected void validateCustomerOrders(Metadata metadata) {
final Collection collectionBinding = metadata.getCollectionBinding(Customer.class.getName() + ".orders");
assertNotNull(collectionBinding);
validateCustomerOrdersTableName(collectionBinding.getCollectionTable().getQuotedName());
assertEquals(1, collectionBinding.getKey().getColumnSpan());
validateCustomerOrdersKeyColumn((Column) collectionBinding.getKey().getColumnIterator().next());
assertEquals(1, collectionBinding.getElement().getColumnSpan());
validateCustomerOrdersElementColumn((Column) collectionBinding.getElement().getColumnIterator().next());
}
use of org.hibernate.mapping.Collection in project hibernate-orm by hibernate.
the class CorrectnessTestCase method buildMetadata.
private Metadata buildMetadata(StandardServiceRegistry registry) {
MetadataSources metadataSources = new MetadataSources(registry);
for (Class entityClass : getAnnotatedClasses()) {
metadataSources.addAnnotatedClass(entityClass);
}
Metadata metadata = metadataSources.buildMetadata();
for (PersistentClass entityBinding : metadata.getEntityBindings()) {
if (!entityBinding.isInherited()) {
((RootClass) entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
}
}
// Collections don't have integrated version, these piggyback on parent's owner version (for DB).
// However, this version number isn't extractable and is not passed to cache methods.
AccessType collectionAccessType = accessType == AccessType.NONSTRICT_READ_WRITE ? AccessType.READ_WRITE : accessType;
for (Collection collectionBinding : metadata.getCollectionBindings()) {
collectionBinding.setCacheConcurrencyStrategy(collectionAccessType.getExternalName());
}
return metadata;
}
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();
}
Aggregations