List of usage examples for org.hibernate.mapping ToOne getColumnIterator
@Override
public Iterator<Selectable> getColumnIterator()
From source file:com.github.shyiko.rook.target.hibernate4.fulltextindex.SynchronizationContext.java
License:Apache License
@SuppressWarnings("unchecked") private PrimaryKey resolveForeignPrimaryKey(org.hibernate.mapping.Collection collection, Map<String, IndexingDirective> directivesByEntityNameMap) { Table collectionTable = collection.getCollectionTable(); ToOne element = (ToOne) collection.getElement(); IndexingDirective indexingDirective = directivesByEntityNameMap.get(element.getReferencedEntityName()); if (indexingDirective == null) { return null; }/*w ww . j a v a 2s . com*/ Collection<String> targetPrimaryKeyColumnNames = new HashSet<String>(); for (Iterator<Column> columnIterator = element.getColumnIterator(); columnIterator.hasNext();) { Column column = columnIterator.next(); targetPrimaryKeyColumnNames.add(column.getName()); } Map<String, Integer> columnIndexByNameMap = new HashMap<String, Integer>(); int index = 0; for (Iterator<Column> columnIterator = collectionTable.getColumnIterator(); columnIterator.hasNext();) { Column column = columnIterator.next(); if (targetPrimaryKeyColumnNames.contains(column.getName())) { columnIndexByNameMap.put(column.getName(), index); } index++; } return new PrimaryKey(indexingDirective.getPrimaryKey(), columnIndexByNameMap); }