当前位置: 首页>>代码示例>>Java>>正文


Java Type类代码示例

本文整理汇总了Java中org.hibernate.type.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Type类属于org.hibernate.type包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDeletes

import org.hibernate.type.Type; //导入依赖的package包/类
@Override
@SuppressWarnings({"deprecation", "unchecked"})
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
	final Type indexType = persister.getIndexType();
	final HashMap snapshot = (HashMap) getSnapshot();
	final HashMap deletes = (HashMap) snapshot.clone();
	deletes.keySet().removeAll( ( (HashMap) getSnapshot( persister ) ).keySet() );
	final ArrayList deleteList = new ArrayList( deletes.size() );
	for ( Object o : deletes.entrySet() ) {
		final Map.Entry me = (Map.Entry) o;
		final Object object = indexIsFormula
				? me.getValue()
				: ( (XmlRepresentableType) indexType ).fromXMLString( (String) me.getKey(), persister.getFactory() );
		if ( object != null ) {
			deleteList.add( object );
		}
	}
	return deleteList.iterator();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:PersistentIndexedElementHolder.java

示例2: cascadeToOne

import org.hibernate.type.Type; //导入依赖的package包/类
/**
 * Cascade an action to a to-one association or any type
 */
private void cascadeToOne(
		final Object parent,
		final Object child,
		final Type type,
		final CascadeStyle style,
		final Object anything,
		final boolean isCascadeDeleteEnabled) {
	final String entityName = type.isEntityType()
			? ( (EntityType) type ).getAssociatedEntityName()
			: null;
	if ( style.reallyDoCascade( action ) ) {
		//not really necessary, but good for consistency...
		eventSource.getPersistenceContext().addChildParent( child, parent );
		try {
			action.cascade( eventSource, child, entityName, anything, isCascadeDeleteEnabled );
		}
		finally {
			eventSource.getPersistenceContext().removeChildParent( child );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Cascade.java

示例3: getResultRow

import org.hibernate.type.Type; //导入依赖的package包/类
@Override
protected Object[] getResultRow(Object[] row, ResultSet rs, SessionImplementor session)
		throws SQLException, HibernateException {
	final Object[] result;
	if ( translator.hasProjection() ) {
		Type[] types = translator.getProjectedTypes();
		result = new Object[types.length];
		String[] columnAliases = translator.getProjectedColumnAliases();
		for ( int i=0, pos=0; i<result.length; i++ ) {
			int numColumns = types[i].getColumnSpan( session.getFactory() );
			if ( numColumns > 1 ) {
		    	String[] typeColumnAliases = ArrayHelper.slice( columnAliases, pos, numColumns );
				result[i] = types[i].nullSafeGet(rs, typeColumnAliases, session, null);
			}
			else {
				result[i] = types[i].nullSafeGet(rs, columnAliases[pos], session, null);
			}
			pos += numColumns;
		}
	}
	else {
		result = toResultRow( row );
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:CriteriaLoader.java

示例4: initCollectionPropertyMap

import org.hibernate.type.Type; //导入依赖的package包/类
private void initCollectionPropertyMap(String aliasName, Type type, String[] columnAliases, String[] columnNames) {

		collectionPropertyColumnAliases.put( aliasName, columnAliases );
		collectionPropertyColumnNames.put( aliasName, columnNames );

		if ( type.isComponentType() ) {
			CompositeType ct = (CompositeType) type;
			String[] propertyNames = ct.getPropertyNames();
			for ( int i = 0; i < propertyNames.length; i++ ) {
				String name = propertyNames[i];
				collectionPropertyColumnAliases.put( aliasName + "." + name, columnAliases[i] );
				collectionPropertyColumnNames.put( aliasName + "." + name, columnNames[i] );
			}
		}

	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:AbstractCollectionPersister.java

示例5: disassemble

import org.hibernate.type.Type; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
	final Type elementType = persister.getElementType();
	final String indexNodeName = getIndexAttributeName( persister );
	final List elements =  element.elements( persister.getElementNodeName() );
	final int length = elements.size();
	final Serializable[] result = new Serializable[length];
	for ( int i=0; i<length; i++ ) {
		final Element elem = (Element) elements.get( i );
		final Object object = elementType.fromXMLNode( elem, persister.getFactory() );
		final Integer index = IntegerType.INSTANCE.fromString( getIndex( elem, indexNodeName, i ) );
		result[index] = elementType.disassemble( object, getSession(), null );
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:PersistentListElementHolder.java

示例6: equalsSnapshot

import org.hibernate.type.Type; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
	final Type elementType = persister.getElementType();
	final ArrayList snapshot = (ArrayList) getSnapshot();
	final List elements = element.elements( persister.getElementNodeName() );
	if ( snapshot.size() != elements.size() ) {
		return false;
	}
	for ( int i=0; i<snapshot.size(); i++ ) {
		final Object old = snapshot.get( i );
		final Element elem = (Element) elements.get( i );
		final Object current = elementType.fromXMLNode( elem, persister.getFactory() );
		if ( elementType.isDirty( old, current, getSession() ) ) {
			return false;
		}
	}
	return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:PersistentElementHolder.java

示例7: findNonNullableTransientEntities

import org.hibernate.type.Type; //导入依赖的package包/类
/**
 * Find all non-nullable references to entities that have not yet
 * been inserted in the database, where the foreign key
 * is a reference to an unsaved transient entity. .
 *
 * @param entityName - the entity name
 * @param entity - the entity instance
 * @param values - insertable properties of the object (including backrefs),
 * possibly with substitutions
 * @param isEarlyInsert - true if the entity needs to be executed as soon as possible
 * (e.g., to generate an ID)
 * @param session - the session
 *
 * @return the transient unsaved entity dependencies that are non-nullable,
 *         or null if there are none.
 */
public static NonNullableTransientDependencies findNonNullableTransientEntities(
		String entityName,
		Object entity,
		Object[] values,
		boolean isEarlyInsert,
		SessionImplementor session) {
	final Nullifier nullifier = new Nullifier( entity, false, isEarlyInsert, session );
	final EntityPersister persister = session.getEntityPersister( entityName, entity );
	final String[] propertyNames = persister.getPropertyNames();
	final Type[] types = persister.getPropertyTypes();
	final boolean[] nullability = persister.getPropertyNullability();
	final NonNullableTransientDependencies nonNullableTransientEntities = new NonNullableTransientDependencies();
	for ( int i = 0; i < types.length; i++ ) {
		collectNonNullableTransientEntities(
				nullifier,
				values[i],
				propertyNames[i],
				types[i],
				nullability[i],
				session,
				nonNullableTransientEntities
		);
	}
	return nonNullableTransientEntities.isEmpty() ? null : nonNullableTransientEntities;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:ForeignKeys.java

示例8: readFrom

import org.hibernate.type.Type; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
		throws HibernateException, SQLException {
	final Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
	final Type elementType = persister.getElementType();
	final Element subElement = element.addElement( persister.getElementNodeName() );
	elementType.setToXMLNode( subElement, object, persister.getFactory() );
	return object;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:PersistentElementHolder.java

示例9: resolveDateTimeArithmeticResultType

import org.hibernate.type.Type; //导入依赖的package包/类
private Type resolveDateTimeArithmeticResultType(Type lhType, Type rhType) {
	// here, we work under the following assumptions:
	//      ------------ valid cases --------------------------------------
	//      1) datetime + {something other than datetime} : always results
	//              in a datetime ( db will catch invalid conversions )
	//      2) datetime - datetime : always results in a DOUBLE
	//      3) datetime - {something other than datetime} : always results
	//              in a datetime ( db will catch invalid conversions )
	//      ------------ invalid cases ------------------------------------
	//      4) datetime + datetime
	//      5) {something other than datetime} - datetime
	//      6) datetime * {any type}
	//      7) datetime / {any type}
	//      8) {any type} / datetime
	// doing so allows us to properly handle parameters as either the left
	// or right side here in the majority of cases
	boolean lhsIsDateTime = isDateTimeType( lhType );
	boolean rhsIsDateTime = isDateTimeType( rhType );

	// handle the (assumed) valid cases:
	// #1 - the only valid datetime addition synatx is one or the other is a datetime (but not both)
	if ( getType() == HqlSqlTokenTypes.PLUS ) {
		// one or the other needs to be a datetime for us to get into this method in the first place...
		return lhsIsDateTime ? lhType : rhType;
	}
	else if ( getType() == HqlSqlTokenTypes.MINUS ) {
		// #3 - note that this is also true of "datetime - :param"...
		if ( lhsIsDateTime && !rhsIsDateTime ) {
			return lhType;
		}
		// #2
		if ( lhsIsDateTime && rhsIsDateTime ) {
			return StandardBasicTypes.DOUBLE;
		}
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:BinaryArithmeticOperatorNode.java

示例10: setParameterList

import org.hibernate.type.Type; //导入依赖的package包/类
@Override
public Query setParameterList(String name, Collection vals, Type type) throws HibernateException {
	if ( !parameterMetadata.getNamedParameterNames().contains( name ) ) {
		throw new IllegalArgumentException("Parameter " + name + " does not exist as a named parameter in [" + getQueryString() + "]");
	}
	namedParameterLists.put( name, new TypedValue( type, vals ) );
	return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AbstractQueryImpl.java

示例11: getDataType

import org.hibernate.type.Type; //导入依赖的package包/类
@Override
public Type getDataType() {
	if ( super.getDataType() == null ) {
		FromElement fromElement = getLhs().getFromElement();
		if ( fromElement == null ) {
			return null;
		}
		// If the lhs is a collection, use CollectionPropertyMapping
		Type propertyType = fromElement.getPropertyType( propertyName, propertyPath );
		LOG.debugf( "getDataType() : %s -> %s", propertyPath, propertyType );
		super.setDataType( propertyType );
	}
	return super.getDataType();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:DotNode.java

示例12: processValues

import org.hibernate.type.Type; //导入依赖的package包/类
/**
 * Dispatch each property value to processValue().
 *
 * @param values
 * @param types
 * @throws HibernateException
 */
void processValues(Object[] values, Type[] types) throws HibernateException {
	for ( int i=0; i<types.length; i++ ) {
		if ( includeProperty(values, i) ) {
			processValue( i, values, types );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AbstractVisitor.java

示例13: buildTypeDiscriminatorMetadata

import org.hibernate.type.Type; //导入依赖的package包/类
private DiscriminatorMetadata buildTypeDiscriminatorMetadata() {
	return new DiscriminatorMetadata() {
		public String getSqlFragment(String sqlQualificationAlias) {
			return toColumns( sqlQualificationAlias, ENTITY_CLASS )[0];
		}

		public Type getResolutionType() {
			return new DiscriminatorType( getDiscriminatorType(), AbstractEntityPersister.this );
		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:AbstractEntityPersister.java

示例14: createDeletedState

import org.hibernate.type.Type; //导入依赖的package包/类
private Object[] createDeletedState(EntityPersister persister, Object[] currentState, EventSource session) {
		Type[] propTypes = persister.getPropertyTypes();
		final Object[] deletedState = new Object[propTypes.length];
//		TypeFactory.deepCopy( currentState, propTypes, persister.getPropertyUpdateability(), deletedState, session );
		boolean[] copyability = new boolean[propTypes.length];
		java.util.Arrays.fill( copyability, true );
		TypeHelper.deepCopy( currentState, propTypes, copyability, deletedState, session );
		return deletedState;
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DefaultDeleteEventListener.java

示例15: toString

import org.hibernate.type.Type; //导入依赖的package包/类
public String toString(Type[] types, Object[] values) throws HibernateException {
	StringBuilder buffer = new StringBuilder();
	for ( int i=0; i<types.length; i++ ) {
		if ( types[i]!=null ) {
			buffer.append( types[i].toLoggableString( values[i], factory ) ).append( ", " );
		}
	}
	return buffer.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:EntityPrinter.java


注:本文中的org.hibernate.type.Type类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。