Example usage for org.hibernate.type CollectionType getElementType

List of usage examples for org.hibernate.type CollectionType getElementType

Introduction

In this page you can find the example usage for org.hibernate.type CollectionType getElementType.

Prototype

public final Type getElementType(SessionFactoryImplementor factory) throws MappingException 

Source Link

Document

Get the Hibernate type of the collection elements

Usage

From source file:org.seasar.hibernate.jpa.metadata.AbstractHibernateAttributeDesc.java

License:Apache License

/**
 * ???//from  w  w  w .j  av a  2  s . c o m
 * 
 * @param factory
 *            
 * @param hibernateType
 *            Hibernate?
 * @param name
 *            ????
 * @param id
 *            ???ID??????
 * @param version
 *            ???????????
 */
public AbstractHibernateAttributeDesc(final SessionFactoryImplementor factory, final Type hibernateType,
        final String name, final boolean id, final boolean version) {
    this.factory = factory;
    this.hibernateType = hibernateType;
    this.name = name;
    this.id = id;
    this.version = version;

    type = hibernateType.getReturnedClass();
    sqlType = getSqlType(hibernateType);

    if (type == Date.class || type == Calendar.class) {
        temporalType = TemporalTypeUtil.fromSqlTypeToTemporalType(sqlType);
    } else {
        temporalType = null;
    }

    association = hibernateType.isAssociationType();
    collection = hibernateType.isCollectionType();
    component = hibernateType.isComponentType();

    if (collection) {
        final CollectionType collectionType = CollectionType.class.cast(hibernateType);
        elementType = collectionType.getElementType(factory).getReturnedClass();
    } else {
        elementType = null;
    }

    if (component) {
        childAttributeDescs = createChildAttributeDescs();
    } else {
        childAttributeDescs = new AttributeDesc[] {};
    }

}