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


Java Getter.get方法代码示例

本文整理汇总了Java中org.hibernate.property.Getter.get方法的典型用法代码示例。如果您正苦于以下问题:Java Getter.get方法的具体用法?Java Getter.get怎么用?Java Getter.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.property.Getter的用法示例。


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

示例1: setProperties

import org.hibernate.property.Getter; //导入方法依赖的package包/类
public Query setProperties(Object bean) throws HibernateException {
	Class clazz = bean.getClass();
	String[] params = getNamedParameters();
	for (int i = 0; i < params.length; i++) {
		String namedParam = params[i];
		try {
			Getter getter = ReflectHelper.getGetter( clazz, namedParam );
			Class retType = getter.getReturnType();
			final Object object = getter.get( bean );
			if ( Collection.class.isAssignableFrom( retType ) ) {
				setParameterList( namedParam, ( Collection ) object );
			}
			else if ( retType.isArray() ) {
			 	setParameterList( namedParam, ( Object[] ) object );
			}
			else {
				setParameter( namedParam, object, determineType( namedParam, retType ) );
			}
		}
		catch (PropertyNotFoundException pnfe) {
			// ignore
		}
	}
	return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:AbstractQueryImpl.java

示例2: getUnsavedVersionValue

import org.hibernate.property.Getter; //导入方法依赖的package包/类
/**
 * Return an IdentifierValue for the specified unsaved-value. If none is specified,
 * guess the unsaved value by instantiating a test instance of the class and
 * reading it's version property value, or if that is not possible, using the java default
 * value for the type
 *
 * @param versionUnsavedValue The mapping defined unsaved value
 * @param versionGetter The version attribute getter
 * @param versionType The mapping type for the version
 * @param constructor The constructor for the entity
 *
 * @return The appropriate VersionValue
 */
public static VersionValue getUnsavedVersionValue(
		String versionUnsavedValue, 
		Getter versionGetter,
		VersionType versionType,
		Constructor constructor) {
	
	if ( versionUnsavedValue == null ) {
		if ( constructor!=null ) {
			final Object defaultValue = versionGetter.get( instantiate( constructor ) );
			// if the version of a newly instantiated object is not the same
			// as the version seed value, use that as the unsaved-value
			return versionType.isEqual( versionType.seed( null ), defaultValue )
					? VersionValue.UNDEFINED
					: new VersionValue( defaultValue );
		}
		else {
			return VersionValue.UNDEFINED;
		}
	}
	else if ( "undefined".equals( versionUnsavedValue ) ) {
		return VersionValue.UNDEFINED;
	}
	else if ( "null".equals( versionUnsavedValue ) ) {
		return VersionValue.NULL;
	}
	else if ( "negative".equals( versionUnsavedValue ) ) {
		return VersionValue.NEGATIVE;
	}
	else {
		// this should not happen since the DTD prevents it
		throw new MappingException( "Could not parse version unsaved-value: " + versionUnsavedValue );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:UnsavedValueFactory.java

示例3: getUnsavedVersionValue

import org.hibernate.property.Getter; //导入方法依赖的package包/类
public static VersionValue getUnsavedVersionValue(
		String versionUnsavedValue, 
		Getter versionGetter,
		VersionType versionType,
		Constructor constructor) {
	
	if ( versionUnsavedValue == null ) {
		if ( constructor!=null ) {
			Object defaultValue = versionGetter.get( instantiate(constructor) );
			// if the version of a newly instantiated object is not the same
			// as the version seed value, use that as the unsaved-value
			return versionType.isEqual( versionType.seed( null ), defaultValue ) ?
					VersionValue.UNDEFINED :
					new VersionValue( defaultValue );
		}
		else {
			return VersionValue.UNDEFINED;
		}
	}
	else if ( "undefined".equals( versionUnsavedValue ) ) {
		return VersionValue.UNDEFINED;
	}
	else if ( "null".equals( versionUnsavedValue ) ) {
		return VersionValue.NULL;
	}
	else if ( "negative".equals( versionUnsavedValue ) ) {
		return VersionValue.NEGATIVE;
	}
	else {
		// this should not happen since the DTD prevents it
		throw new MappingException( "Could not parse version unsaved-value: " + versionUnsavedValue );
	}
	
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:35,代码来源:UnsavedValueFactory.java

示例4: testStringElementExtraction

import org.hibernate.property.Getter; //导入方法依赖的package包/类
public void testStringElementExtraction() throws Throwable {
	Property property = generateNameProperty();
	Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
			.getGetter( null, null );
	String name = ( String ) getter.get( DOM );
	assertEquals( "Not equals", "JBoss", name );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:Dom4jAccessorTest.java

示例5: testStringTextExtraction

import org.hibernate.property.Getter; //导入方法依赖的package包/类
public void testStringTextExtraction() throws Throwable {
	Property property = generateTextProperty();
	Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
			.getGetter( null, null );
	String name = ( String ) getter.get( DOM );
	assertEquals( "Not equals", "description...", name );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:Dom4jAccessorTest.java

示例6: testLongAttributeExtraction

import org.hibernate.property.Getter; //导入方法依赖的package包/类
public void testLongAttributeExtraction() throws Throwable {
	Property property = generateIdProperty();
	Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
			.getGetter( null, null );
	Long id = ( Long ) getter.get( DOM );
	assertEquals( "Not equals", new Long( 123 ), id );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:Dom4jAccessorTest.java

示例7: testLongElementAttributeExtraction

import org.hibernate.property.Getter; //导入方法依赖的package包/类
public void testLongElementAttributeExtraction() throws Throwable {
	Property property = generateAccountIdProperty();
	Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
			.getGetter( null, null );
	Long id = ( Long ) getter.get( DOM );
	assertEquals( "Not equals", new Long( 456 ), id );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:Dom4jAccessorTest.java

示例8: extractColumnValues

import org.hibernate.property.Getter; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public String extractColumnValues(){
	StringBuffer sb = new StringBuffer();
	//add the pk column and value
	sb.append(extractPrimaryKeyColumn() + " = " + extractPrimaryKeyValue() + " | ");
	//loop through all the other properties and get what you need
	for (String p: properties){
		Property pr = pc.getProperty(p);
	
		//make sure that this is not a collection and not a one to one as these values are not part of the table
		if (!pr.getType().isCollectionType() && !(pr.getType() instanceof OneToOneType)) {
			//make sure that the values are persistent values and not a forumla value
			if (pr.isInsertable() || pr.isUpdateable()) {
				int scale = 2;
				//get the getter for the entity
				Getter getter = pr.getGetter(entity.getClass());
				//get column value
				Object columnValue = getter.get(entity);
				//get column name
				for (Iterator it3 = pr.getColumnIterator(); it3.hasNext();) {
					Column column = (Column)it3.next();
					sb.append(column.getName());
					scale = column.getScale();
				}
				sb.append(" = ");
				//check what kind of type of value this is, it if it an association then get the forign key value from the associated entity
				if (columnValue != null) {
					if (!pr.getType().isAssociationType()) {
						//if bigD set Scale
						if (columnValue instanceof BigDecimal) {
							columnValue = ((BigDecimal)columnValue).setScale(scale,BigDecimal.ROUND_HALF_DOWN);
						} else if (columnValue instanceof java.util.Date) {
							SimpleDateFormat sdf = null;
							if(columnValue instanceof java.sql.Timestamp){
								sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
							}else{
								sdf = new SimpleDateFormat(DATE_FORMAT);
							}
							columnValue = sdf.format(columnValue);
						} else if (pr.getType().getName().equalsIgnoreCase("org.springframework.orm.hibernate3.support.ClobStringType")){
							columnValue = "Clob Value";
						}
						sb.append(columnValue);
					} else {
						//since it's an association we know that column value is an object
						String associatedEntityName = pr.getType().getName();
						//associatedEntityName = ((EntityType)pr.getType()).getAssociatedEntityName ();
						PersistentClass localPC = extractPersistentClass(associatedEntityName);
						String fkValue = extractPrimaryKeyValue(localPC,columnValue);
						sb.append(fkValue);
					}
				}
				sb.append(" | ");
			}
		}
	}
	return sb.toString();
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:59,代码来源:EntityParser.java


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