List of usage examples for org.hibernate.persister.collection AbstractCollectionPersister getIndexColumnNames
@Override
public String[] getIndexColumnNames()
From source file:org.eclipse.emf.teneo.hibernate.LazyCollectionUtils.java
License:Open Source License
/** * Returns an iterator which loads the underlying data from the collection * in pages (controlled by the pageSize parameter). Note if the collection * is not lazy loadable then a normal iterator is returned. This is checked * using the {@link #isLazyLoadableCollection(Collection)} method. * /*from ww w . j a v a 2 s . c om*/ * Note: this method can only handle collections of EObjects so not collections * of primitive typed objects. Paged iteration of these collections is not * supported by Hibernate. * * @param coll * the collection to iterate lazily over * @param pageSize * the pageSize, this determines the pagesize of the page of data * read each time from the database * @return a paging iterator or if not a lazy loadable collection a normal * iterator * @see PagingIterator */ public static <E> Iterator<E> getPagedLoadingIterator(Collection<E> coll, int pageSize) { if (!isLazyLoadableCollection(coll)) { return coll.iterator(); } final PersistableDelegateList<?> persistableList = (PersistableDelegateList<?>) coll; final AbstractPersistentCollection persistentCollection = (AbstractPersistentCollection) persistableList .getDelegate(); final SessionImplementor session = persistentCollection.getSession(); final PagingIterator<E> pagingIterator = new PagingIterator<E>(); pagingIterator.setCollection(persistentCollection); pagingIterator.setPageSize(pageSize); pagingIterator.setSession((Session) session); final CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(persistentCollection); final AbstractCollectionPersister persister = (AbstractCollectionPersister) entry.getLoadedPersister(); pagingIterator.setEavCollection(coll instanceof EAVDelegatingList); pagingIterator.setIndexColumnNames(persister.getIndexColumnNames()); return pagingIterator; }
From source file:org.riotfamily.core.dao.hibernate.HqlIndexedListDao.java
License:Apache License
@Override protected void initDao() throws Exception { super.initDao(); AbstractCollectionPersister persister = (AbstractCollectionPersister) getSessionFactory() .getCollectionMetadata(getRole()); indexColumn = persister.getIndexColumnNames()[0]; }