Java 类org.hibernate.type.NullableType 实例源码

项目:cacheonix-core    文件:PersistentMapElementHolder.java   
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
throws HibernateException {

    Type elementType = persister.getElementType();
    Type indexType = persister.getIndexType();
    final String indexNodeName = getIndexAttributeName(persister);

    Serializable[] cached = (Serializable[]) disassembled;

    for ( int i=0; i<cached.length; ) {
        Object index = indexType.assemble( cached[i++], getSession(), owner );
        Object object = elementType.assemble( cached[i++], getSession(), owner );

        Element subelement = element.addElement( persister.getElementNodeName() );
        elementType.setToXMLNode( subelement, object, persister.getFactory() );

        String indexString = ( (NullableType) indexType ).toXMLString( index, persister.getFactory() );
        setIndex( subelement, indexNodeName, indexString );
    }

}
项目:cacheonix-core    文件:PersistentMapElementHolder.java   
public Serializable disassemble(CollectionPersister persister) throws HibernateException {

    Type elementType = persister.getElementType();
    Type indexType = persister.getIndexType();
    final String indexNodeName = getIndexAttributeName(persister);

    List elements =  element.elements( persister.getElementNodeName() );
    int length = elements.size();
    Serializable[] result = new Serializable[length*2];
    for ( int i=0; i<length*2; ) {
        Element elem = (Element) elements.get(i/2);
        Object object = elementType.fromXMLNode( elem, persister.getFactory() );
        final String indexString = getIndex(elem, indexNodeName, i);
        Object index = ( (NullableType) indexType ).fromXMLString( indexString, persister.getFactory() );
        result[i++] = indexType.disassemble( index, getSession(), null );
        result[i++] = elementType.disassemble( object, getSession(), null );
    }
    return result;
}
项目:cacheonix-core    文件:PersistentIndexedElementHolder.java   
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
throws HibernateException, SQLException {
    Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
    final Type elementType = persister.getElementType();
    final SessionFactoryImplementor factory = persister.getFactory();
    String indexNode = getIndexAttributeName(persister);

    Element elem = element.addElement( persister.getElementNodeName() );
    elementType.setToXMLNode( elem, object, factory ); 

    final Type indexType = persister.getIndexType();
    final Object indexValue = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
    final String index = ( (NullableType) indexType ).toXMLString( indexValue, factory );
    setIndex(elem, indexNode, index);
    return object;
}
项目:cacheonix-core    文件:PersistentIndexedElementHolder.java   
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) 
throws HibernateException {

    final Type indexType = persister.getIndexType();
    HashMap snapshot = (HashMap) getSnapshot();
    HashMap deletes = (HashMap) snapshot.clone();
    deletes.keySet().removeAll( ( (HashMap) getSnapshot(persister) ).keySet() );
    ArrayList deleteList = new ArrayList( deletes.size() );
    Iterator iter = deletes.entrySet().iterator();
    while ( iter.hasNext() ) {
        Map.Entry me = (Map.Entry) iter.next();
        final Object object = indexIsFormula ?
            me.getValue() :
            ( (NullableType) indexType ).fromXMLString( (String) me.getKey(), persister.getFactory() );
        if (object!=null) deleteList.add(object);
    }

    return deleteList.iterator();

}
项目:cacheonix-core    文件:CriteriaQueryTranslator.java   
/**
 * Get the a typed value for the given property value.
 */
public TypedValue getTypedValue(Criteria subcriteria, String propertyName, Object value)
        throws HibernateException {
    // Detect discriminator values...
    if ( value instanceof Class ) {
        Class entityClass = ( Class ) value;
        Queryable q = SessionFactoryHelper.findQueryableUsingImports( sessionFactory, entityClass.getName() );
        if ( q != null ) {
            Type type = q.getDiscriminatorType();
            String stringValue = q.getDiscriminatorSQLValue();
            // Convert the string value into the proper type.
            if ( type instanceof NullableType ) {
                NullableType nullableType = ( NullableType ) type;
                value = nullableType.fromStringValue( stringValue );
            }
            else {
                throw new QueryException( "Unsupported discriminator type " + type );
            }
            return new TypedValue(
                    type,
                    value,
                    EntityMode.POJO
            );
        }
    }
    // Otherwise, this is an ordinary value.
    return new TypedValue(
            getTypeUsingProjection( subcriteria, propertyName ),
            value,
            EntityMode.POJO
    );
}
项目:cacheonix-core    文件:PersistentIndexedElementHolder.java   
public Object getIndex(Object entry, int i, CollectionPersister persister) {
    String index = ( (IndexedValue) entry ).index;
    final Type indexType = persister.getIndexType();
    return ( (NullableType) indexType ).fromXMLString( index, persister.getFactory() );
}
项目:ephesoft    文件:DynamicHibernateDao.java   
/**
 * Constructor.
 *  
 * @param alias String
 * @param type NullableType
 */
public AliasType(String alias, NullableType type) {
    this.alias = alias;
    this.type = type;
}