use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class CollectionMetadataGenerator method searchMappedByKey.
@SuppressWarnings({ "unchecked" })
private String searchMappedByKey(PersistentClass referencedClass, Collection collectionValue) {
final Iterator<Value> assocIdClassProps = referencedClass.getKeyClosureIterator();
while (assocIdClassProps.hasNext()) {
final Value value = assocIdClassProps.next();
// make sure its a 'Component' because IdClass is registered as this type.
if (value instanceof Component) {
final Component component = (Component) value;
final Iterator<Property> componentPropertyIterator = component.getPropertyIterator();
while (componentPropertyIterator.hasNext()) {
final Property property = componentPropertyIterator.next();
final Iterator<Selectable> propertySelectables = property.getValue().getColumnIterator();
final Iterator<Selectable> collectionSelectables = collectionValue.getKey().getColumnIterator();
if (Tools.iteratorsContentEqual(propertySelectables, collectionSelectables)) {
return property.getName();
}
}
}
}
return null;
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class EntityMetamodel method interpretPartialCompositeValueGeneration.
private static void interpretPartialCompositeValueGeneration(SessionFactoryImplementor sessionFactory, Component composite, CompositeGenerationStrategyPairBuilder builder) {
Iterator subProperties = composite.getPropertyIterator();
while (subProperties.hasNext()) {
final Property subProperty = (Property) subProperties.next();
builder.addPair(buildGenerationStrategyPair(sessionFactory, subProperty));
}
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class EntityMetamodel method mapPropertyToIndex.
private void mapPropertyToIndex(Property prop, int i) {
propertyIndexes.put(prop.getName(), i);
if (prop.getValue() instanceof Component) {
Iterator iter = ((Component) prop.getValue()).getPropertyIterator();
while (iter.hasNext()) {
Property subprop = (Property) iter.next();
propertyIndexes.put(prop.getName() + '.' + subprop.getName(), i);
}
}
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class AbstractJPAIndexTest method testCollectionTableIndex.
@Test
public void testCollectionTableIndex() {
PersistentClass entity = metadata().getEntityBinding(Car.class.getName());
Property property = entity.getProperty("otherDealers");
Set set = (Set) 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("name", column.getName());
assertSame(collectionTable, index.getTable());
}
use of org.hibernate.mapping.Property 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());
}
Aggregations