Example usage for org.hibernate.persister.collection CollectionPersister readElement

List of usage examples for org.hibernate.persister.collection CollectionPersister readElement

Introduction

In this page you can find the example usage for org.hibernate.persister.collection CollectionPersister readElement.

Prototype

Object readElement(ResultSet rs, Object owner, String[] columnAliases, SharedSessionContractImplementor session)
        throws HibernateException, SQLException;

Source Link

Document

Read the element from a row of the JDBC ResultSet

Usage

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

License:Open Source License

@SuppressWarnings("unchecked")
@Override/* www . ja v a  2s .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/* ww  w . j  ava2  s . c o m*/
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;
}

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

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from   w  ww  .j  a v a2s.  c o  m
public E readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
        throws HibernateException, SQLException {
    E element = (E) persister.readElement(rs, owner, descriptor.getSuffixedElementAliases(), this.getSession());
    if (element != null) {
        this.tempList.add(element);
    }
    return element;
}