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


Java TypedValue类代码示例

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


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

示例1: makeCaller

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
static Object makeCaller ( Object tpl, Object getters ) throws NoSuchMethodException, InstantiationException, IllegalAccessException,
        InvocationTargetException, NoSuchFieldException, Exception, ClassNotFoundException {
    PojoComponentTuplizer tup = Reflections.createWithoutConstructor(PojoComponentTuplizer.class);
    Reflections.getField(AbstractComponentTuplizer.class, "getters").set(tup, getters);

    ComponentType t = Reflections.createWithConstructor(ComponentType.class, AbstractType.class, new Class[0], new Object[0]);
    Reflections.setFieldValue(t, "componentTuplizer", tup);
    Reflections.setFieldValue(t, "propertySpan", 1);
    Reflections.setFieldValue(t, "propertyTypes", new Type[] {
        t
    });

    TypedValue v1 = new TypedValue(t, null);
    Reflections.setFieldValue(v1, "value", tpl);
    Reflections.setFieldValue(v1, "type", t);

    TypedValue v2 = new TypedValue(t, null);
    Reflections.setFieldValue(v2, "value", tpl);
    Reflections.setFieldValue(v2, "type", t);

    return Gadgets.makeMap(v1, v2);
}
 
开发者ID:hucheat,项目名称:APacheSynapseSimplePOC,代码行数:23,代码来源:Hibernate1.java

示例2: addComponentTypedValues

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
protected void addComponentTypedValues(
		String path, 
		Object component, 
		CompositeType type,
		List<TypedValue> list,
		Criteria criteria, 
		CriteriaQuery criteriaQuery) {
	if ( component != null ) {
		final String[] propertyNames = type.getPropertyNames();
		final Type[] subtypes = type.getSubtypes();
		final Object[] values = type.getPropertyValues( component, getEntityMode( criteria, criteriaQuery ) );
		for ( int i=0; i<propertyNames.length; i++ ) {
			final Object value = values[i];
			final Type subtype = subtypes[i];
			final String subpath = StringHelper.qualify( path, propertyNames[i] );
			if ( isPropertyIncluded( value, subpath, subtype ) ) {
				if ( subtype.isComponentType() ) {
					addComponentTypedValues( subpath, value, (CompositeType) subtype, list, criteria, criteriaQuery );
				}
				else {
					addPropertyTypedValue( value, subtype, list );
				}
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:Example.java

示例3: loadCollectionSubselect

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
/**
 * Called by subclasses that batch initialize collections
 */
protected final void loadCollectionSubselect(
		final SessionImplementor session,
		final Serializable[] ids,
		final Object[] parameterValues,
		final Type[] parameterTypes,
		final Map<String, TypedValue> namedParameters,
		final Type type) throws HibernateException {

	Type[] idTypes = new Type[ids.length];
	Arrays.fill( idTypes, type );
	try {
		doQueryAndInitializeNonLazyCollections( session,
				new QueryParameters( parameterTypes, parameterValues, namedParameters, ids ),
				true
			);
	}
	catch ( SQLException sqle ) {
		throw factory.getSQLExceptionHelper().convert(
				sqle,
				"could not load collection by subselect: " +
				MessageHelper.collectionInfoString( getCollectionPersisters()[0], ids, getFactory() ),
				getSQLString()
			);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:Loader.java

示例4: getTypedValues

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) {
	final EntityPersister meta = criteriaQuery.getFactory().getEntityPersister(
			criteriaQuery.getEntityName( criteria )
	);
	final String[] propertyNames = meta.getPropertyNames();
	final Type[] propertyTypes = meta.getPropertyTypes();

	final Object[] values = meta.getPropertyValues( exampleEntity );
	final List<TypedValue> list = new ArrayList<TypedValue>();
	for ( int i=0; i<propertyNames.length; i++ ) {
		final Object value = values[i];
		final Type type = propertyTypes[i];
		final String name = propertyNames[i];

		final boolean isVersionProperty = i == meta.getVersionProperty();

		if ( ! isVersionProperty && isPropertyIncluded( value, name, type ) ) {
			if ( propertyTypes[i].isComponentType() ) {
				addComponentTypedValues( name, value, (CompositeType) type, list, criteria, criteriaQuery );
			}
			else {
				addPropertyTypedValue( value, type, list );
			}
		}
	}

	return list.toArray( new TypedValue[ list.size() ] );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:Example.java

示例5: addPropertyTypedValue

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
protected void addPropertyTypedValue(Object value, Type type, List<TypedValue> list) {
	if ( value != null ) {
		if ( value instanceof String ) {
			String string = (String) value;
			if ( isIgnoreCaseEnabled ) {
				string = string.toLowerCase();
			}
			if ( isLikeEnabled ) {
				string = matchMode.toMatchString( string );
			}
			value = string;
		}
		list.add( new TypedValue( type, value ) );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:Example.java

示例6: getTypedValues

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
	return new TypedValue[] {
			criteriaQuery.getTypedValue( criteria, propertyName, lo ),
			criteriaQuery.getTypedValue( criteria, propertyName, hi )
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:BetweenExpression.java

示例7: getTypedValues

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) {
	return new TypedValue[] {
			criteriaQuery.getTypedValue(
					criteria,
					propertyName,
					value.toString().toLowerCase()
			)
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:IlikeExpression.java

示例8: getTypedValues

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
	final TypedValue[] subQueryTypedValues = super.getTypedValues( criteria, criteriaQuery );
	final TypedValue[] result = new TypedValue[subQueryTypedValues.length+1];
	System.arraycopy( subQueryTypedValues, 0, result, 1, subQueryTypedValues.length );
	result[0] = new TypedValue( getTypes()[0], value );
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:SimpleSubqueryExpression.java

示例9: getTypedValues

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
	//the following two lines were added to ensure that this.params is not null, which
	//can happen with two-deep nested subqueries
	final SessionFactoryImplementor factory = criteriaQuery.getFactory();
	createAndSetInnerQuery( criteriaQuery, factory );

	final Type[] ppTypes = params.getPositionalParameterTypes();
	final Object[] ppValues = params.getPositionalParameterValues();
	final TypedValue[] tv = new TypedValue[ppTypes.length];
	for ( int i=0; i<ppTypes.length; i++ ) {
		tv[i] = new TypedValue( ppTypes[i], ppValues[i] );
	}
	return tv;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:SubqueryExpression.java

示例10: getTypedValues

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) {
	final TypedValue[] lhsTypedValues = lhs.getTypedValues( criteria, criteriaQuery );
	final TypedValue[] rhsTypedValues = rhs.getTypedValues( criteria, criteriaQuery );

	final TypedValue[] result = new TypedValue[ lhsTypedValues.length + rhsTypedValues.length ];
	System.arraycopy( lhsTypedValues, 0, result, 0, lhsTypedValues.length );
	System.arraycopy( rhsTypedValues, 0, result, lhsTypedValues.length, rhsTypedValues.length );
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:LogicalExpression.java

示例11: SQLCriterion

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
protected SQLCriterion(String sql, Object[] values, Type[] types) {
	this.sql = sql;
	this.typedValues = new TypedValue[values.length];
	for ( int i=0; i<typedValues.length; i++ ) {
		typedValues[i] = new TypedValue( types[i], values[i] );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SQLCriterion.java

示例12: getTypedValues

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
@Override
public TypedValue[] getTypedValues(Criteria crit, CriteriaQuery criteriaQuery) throws HibernateException {
	final ArrayList<TypedValue> typedValues = new ArrayList<TypedValue>();
	for ( Criterion condition : conditions ) {
		final TypedValue[] subValues = condition.getTypedValues( crit, criteriaQuery );
		Collections.addAll( typedValues, subValues );
	}
	return typedValues.toArray( new TypedValue[ typedValues.size() ] );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:Junction.java

示例13: getTypedValue

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
/**
 * Get the a typed value for the given property value.
 */
@Override
public TypedValue getTypedValue(Criteria subcriteria, String propertyName, Object value) throws HibernateException {
	// Detect discriminator values...
	if ( value instanceof Class ) {
		final Class entityClass = (Class) value;
		final Queryable q = SessionFactoryHelper.findQueryableUsingImports( sessionFactory, entityClass.getName() );
		if ( q != null ) {
			final Type type = q.getDiscriminatorType();
			String stringValue = q.getDiscriminatorSQLValue();
			if ( stringValue != null
					&& stringValue.length() > 2
					&& stringValue.startsWith( "'" )
					&& stringValue.endsWith( "'" ) ) {
				// remove the single quotes
				stringValue = stringValue.substring( 1, stringValue.length() - 1 );
			}
			
			// Convert the string value into the proper type.
			if ( type instanceof StringRepresentableType ) {
				final StringRepresentableType nullableType = (StringRepresentableType) type;
				value = nullableType.fromStringValue( stringValue );
			}
			else {
				throw new QueryException( "Unsupported discriminator type " + type );
			}
			return new TypedValue( type, value );
		}
	}
	// Otherwise, this is an ordinary value.
	return new TypedValue( getTypeUsingProjection( subcriteria, propertyName ), value );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:CriteriaQueryTranslator.java

示例14: bindNamedParameters

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
/**
 * Bind named parameters to the JDBC prepared statement.
 * <p/>
 * This is a generic implementation, the problem being that in the
 * general case we do not know enough information about the named
 * parameters to perform this in a complete manner here.  Thus this
 * is generally overridden on subclasses allowing named parameters to
 * apply the specific behavior.  The most usual limitation here is that
 * we need to assume the type span is always one...
 *
 * @param statement The JDBC prepared statement
 * @param namedParams A map of parameter names to values
 * @param startIndex The position from which to start binding parameter values.
 * @param session The originating session.
 * @return The number of JDBC bind positions actually bound during this method execution.
 * @throws SQLException Indicates problems performing the binding.
 * @throws org.hibernate.HibernateException Indicates problems delegating binding to the types.
 */
protected int bindNamedParameters(
		final PreparedStatement statement,
		final Map<String, TypedValue> namedParams,
		final int startIndex,
		final SessionImplementor session) throws SQLException, HibernateException {
	int result = 0;
	if ( CollectionHelper.isEmpty( namedParams ) ) {
		return result;
	}

	for ( String name : namedParams.keySet() ) {
		TypedValue typedValue = namedParams.get( name );
		int columnSpan = typedValue.getType().getColumnSpan( getFactory() );
		int[] locs = getNamedParameterLocs( name );
		for ( int loc : locs ) {
			if ( DEBUG_ENABLED ) {
				LOG.debugf(
						"bindNamedParameters() %s -> %s [%s]",
						typedValue.getValue(),
						name,
						loc + startIndex
				);
			}
			int start = loc * columnSpan + startIndex;
			typedValue.getType().nullSafeSet( statement, typedValue.getValue(), start, session );
		}
		result += locs.length;
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:Loader.java

示例15: bindNamedParameters

import org.hibernate.engine.spi.TypedValue; //导入依赖的package包/类
/**
 * Bind named parameters to the JDBC prepared statement.
 * <p/>
 * This is a generic implementation, the problem being that in the
 * general case we do not know enough information about the named
 * parameters to perform this in a complete manner here.  Thus this
 * is generally overridden on subclasses allowing named parameters to
 * apply the specific behavior.  The most usual limitation here is that
 * we need to assume the type span is always one...
 *
 * @param statement The JDBC prepared statement
 * @param namedParams A map of parameter names to values
 * @param startIndex The position from which to start binding parameter values.
 * @param session The originating session.
 * @return The number of JDBC bind positions actually bound during this method execution.
 * @throws SQLException Indicates problems performing the binding.
 * @throws org.hibernate.HibernateException Indicates problems delegating binding to the types.
 */
protected int bindNamedParameters(
		final PreparedStatement statement,
		final Map namedParams,
		final int startIndex,
		final SessionImplementor session) throws SQLException, HibernateException {
	if ( namedParams != null ) {
		// assumes that types are all of span 1
		final Iterator itr = namedParams.entrySet().iterator();
		final boolean debugEnabled = log.isDebugEnabled();
		int result = 0;
		while ( itr.hasNext() ) {
			final Map.Entry e = (Map.Entry) itr.next();
			final String name = (String) e.getKey();
			final TypedValue typedval = (TypedValue) e.getValue();
			final int[] locs = getNamedParameterLocs( name );
			for ( int loc : locs ) {
				if ( debugEnabled ) {
					log.debugf(
							"bindNamedParameters() %s -> %s [%s]",
							typedval.getValue(),
							name,
							loc + startIndex
					);
				}
				typedval.getType().nullSafeSet( statement, typedval.getValue(), loc + startIndex, session );
			}
			result += locs.length;
		}
		return result;
	}
	else {
		return 0;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:53,代码来源:AbstractLoadPlanBasedLoader.java


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