Example usage for org.hibernate.loader CollectionAliases getSuffixedIndexAliases

List of usage examples for org.hibernate.loader CollectionAliases getSuffixedIndexAliases

Introduction

In this page you can find the example usage for org.hibernate.loader CollectionAliases getSuffixedIndexAliases.

Prototype

public String[] getSuffixedIndexAliases();

Source Link

Document

Returns the suffixed result-set column-aliases for the collumns making up the collection's index (map or list).

Usage

From source file:org.babyfish.hibernate.collection.spi.persistence.ListBasePersistence.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from   w  w  w.j av a2 s.  co m*/
public E readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
        throws HibernateException, SQLException {
    List<E> baseList = this.getBase();
    E element = (E) persister.readElement(rs, owner, descriptor.getSuffixedElementAliases(), this.getSession());
    int index = ((Integer) persister.readIndex(rs, descriptor.getSuffixedIndexAliases(), this.getSession()))
            .intValue();
    //pad with nulls from the current last element up to the new index
    for (int i = baseList.size(); i <= index; i++) {
        baseList.add(i, null);
    }
    baseList.set(index, element);
    return element;
}

From source file:org.babyfish.hibernate.collection.spi.persistence.MapBasePersistence.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//w  ww.j av a2s .c om
public V readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
        throws HibernateException, SQLException {
    V value = (V) persister.readElement(rs, owner, descriptor.getSuffixedElementAliases(), getSession());
    K key = (K) persister.readIndex(rs, descriptor.getSuffixedIndexAliases(), getSession());
    if (value != null) {
        this.getBase().put(key, value);
    }
    return value;
}