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


Java ComponentType.getPropertyNames方法代码示例

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


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

示例1: getEmbeddedKeyPropertyIds

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
/**
 * This is an HbnContainer specific utility method that is used to retrieve the list of embedded property key
 * identifiers.
 */
protected Collection<String> getEmbeddedKeyPropertyIds()
{
	logger.executionTrace();

	final ArrayList<String> embeddedKeyPropertyIds = new ArrayList<String>();
	final Type identifierType = classMetadata.getIdentifierType();

	if (identifierType.isComponentType())
	{
		final ComponentType idComponent = (ComponentType) identifierType;
		final String[] propertyNameArray = idComponent.getPropertyNames();

		if (propertyNameArray != null)
		{
			final List<String> propertyNames = Arrays.asList(propertyNameArray);
			embeddedKeyPropertyIds.addAll(propertyNames);
		}
	}

	return embeddedKeyPropertyIds;
}
 
开发者ID:alejandro-du,项目名称:enterprise-app,代码行数:26,代码来源:CustomHbnContainer.java

示例2: propertyInEmbeddedKey

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
/**
 * This is an internal HbnContainer utility method. Determines if a property is contained within an embedded key.
 */
protected boolean propertyInEmbeddedKey(Object propertyId)
{
	logger.executionTrace();

	if (embeddedPropertiesCache.containsKey(propertyId))
		return embeddedPropertiesCache.get(propertyId);

	final Type identifierType = classMetadata.getIdentifierType();

	if (identifierType.isComponentType())
	{
		final ComponentType componentType = (ComponentType) identifierType;
		final String[] idPropertyNames = componentType.getPropertyNames();
		final List<String> idPropertyNameList = Arrays.asList(idPropertyNames);
		return idPropertyNameList.contains(propertyId);
	}

	return false;
}
 
开发者ID:alejandro-du,项目名称:enterprise-app,代码行数:23,代码来源:CustomHbnContainer.java

示例3: appendComponentIds

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
/**
 * Private helper method to construct component ids with an optional alias.
 *
 * @param sb
 *            a {@link StringBuffer}
 * @param componentType
 *            the {@link ComponentType}
 * @param criteriaQuery
 *            the {@link CriteriaQuery}
 * @param criteria
 *            the {@link Criteria}
 * @param position
 *            the position of the alias, appened if >= 0
 */
private void appendComponentIds(final StringBuffer sb,
		final ComponentType componentType, final CriteriaQuery criteriaQuery,
		final Criteria criteria, final Integer position)
{
	final String[] idProperties = componentType.getPropertyNames();
	int currPos = position != null ? position.intValue() : -1;
	for (int i = 0; i < idProperties.length; i++)
	{
		sb.append(criteriaQuery.getColumn(criteria, groupByProperty + "."
				+ idProperties[i]));

		if (currPos >= 0)
		{
			sb.append(" as y").append(currPos).append('_');
			currPos++;
		}

		if (i + 1 < idProperties.length)
		{
			sb.append(", ");
		}
	}
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:38,代码来源:GroupByHavingProjection.java

示例4: ComponentCollectionCriteriaInfoProvider

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
ComponentCollectionCriteriaInfoProvider(QueryableCollection persister) {
	this.persister = persister;
	if ( !persister.getElementType().isComponentType() ) {
		throw new IllegalArgumentException( "persister for role " + persister.getRole() + " is not a collection-of-component" );
	}

	ComponentType componentType = (ComponentType) persister.getElementType();
	String[] names = componentType.getPropertyNames();
	Type[] types = componentType.getSubtypes();

	for ( int i = 0; i < names.length; i++ ) {
		subTypes.put( names[i], types[i] );
	}

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

示例5: findSubPropertyIndex

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
private int findSubPropertyIndex(ComponentType type, String subPropertyName) {
	final String[] propertyNames = type.getPropertyNames();
	for ( int index = 0; index<propertyNames.length; index++ ) {
		if ( subPropertyName.equals( propertyNames[index] ) ) {
			return index;
		}
	}
	throw new MappingException( "component property not found: " + subPropertyName );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AbstractEntityTuplizer.java

示例6: getComponentValue

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
/**
 * Extract a component property value.
 *
 * @param type The component property types.
 * @param component The component instance itself.
 * @param propertyPath The property path for the property to be extracted.
 * @return The property value extracted.
 */
protected Object getComponentValue(ComponentType type, Object component, String propertyPath) {
	
	int loc = propertyPath.indexOf('.');
	String basePropertyName = loc>0 ?
		propertyPath.substring(0, loc) : propertyPath;
	
	String[] propertyNames = type.getPropertyNames();
	int index=0;
	for ( ; index<propertyNames.length; index++ ) {
		if ( basePropertyName.equals( propertyNames[index] ) ) break;
	}
	if (index==propertyNames.length) {
		throw new MappingException( "component property not found: " + basePropertyName );
	}
	
	Object baseValue = type.getPropertyValue( component, index, getEntityMode() );
	
	if ( loc>0 ) {
		ComponentType subtype = (ComponentType) type.getSubtypes()[index];
		return getComponentValue( subtype, baseValue, propertyPath.substring(loc+1) );
	}
	else {
		return baseValue;
	}
	
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:35,代码来源:AbstractEntityTuplizer.java

示例7: fixupComponentRelationships

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
/**
 * Connect the related entities based on the foreign key values found in a component type.
 * This updates the values of the component's properties.
 * @param propName Name of the (component) property of the entity.  May be null if the property is the entity's identifier.
 * @param compType Type of the component
 * @param entityInfo Breeze EntityInfo
 * @param meta Metadata for the entity class
 */
private void fixupComponentRelationships(String propName, ComponentType compType, EntityInfo entityInfo, ClassMetadata meta) {
    String[] compPropNames = compType.getPropertyNames();
    Type[] compPropTypes = compType.getSubtypes();
    Object component = null;
    Object[] compValues = null;
    boolean isChanged = false;
    for (int j = 0; j < compPropNames.length; j++) {
        Type compPropType = compPropTypes[j];
        if (compPropType.isAssociationType() && compPropType.isEntityType())  {
            if (compValues == null) {
                // get the value of the component's subproperties
                component = getPropertyValue(meta, entityInfo.entity, propName);
                compValues = compType.getPropertyValues(component, EntityMode.POJO);
            }
            if (compValues[j] == null) {
                // the related entity is null
                Object relatedEntity = getRelatedEntity(compPropNames[j], (EntityType) compPropType, entityInfo, meta);
                if (relatedEntity != null)  {
                    compValues[j] = relatedEntity;
                    isChanged = true;
                }
            } else if (removeMode) {
                // remove the relationship
                compValues[j] = null;
                isChanged = true;
            }
        }
    }
    if (isChanged) {
        compType.setPropertyValues(component, compValues, EntityMode.POJO);
    }
}
 
开发者ID:Breeze,项目名称:breeze.server.java,代码行数:41,代码来源:RelationshipFixer.java

示例8: getType

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
/**
 * Gets the data type of all Properties identified by the given Property ID. This method does pretty much the same
 * thing as EntityItemProperty#getType()
 */
public Class<?> getType(Object propertyId)
{
	logger.executionTrace();

	// TODO: refactor to use same code as EntityItemProperty#getType()
	// This will also fix incomplete implementation of this method (for association types). Not critical as
	// Components don't really rely on this methods.

	if (addedProperties.keySet().contains(propertyId))
		return addedProperties.get(propertyId);

	if (propertyInEmbeddedKey(propertyId))
	{
		final ComponentType idType = (ComponentType) classMetadata.getIdentifierType();
		final String[] propertyNames = idType.getPropertyNames();

		for (int i = 0; i < propertyNames.length; i++)
		{
			String name = propertyNames[i];
			if (name.equals(propertyId))
			{
				String idName = classMetadata.getIdentifierPropertyName();
				try
				{
					Field idField = entityType.getDeclaredField(idName);
					Field propertyField = idField.getType().getDeclaredField((String) propertyId);
					return propertyField.getType();
				}
				catch (NoSuchFieldException ex)
				{
					throw new RuntimeException("Could not find the type of specified container property.", ex);
				}
			}
		}
	}

	Type propertyType = classMetadata.getPropertyType(propertyId.toString());
	return propertyType.getReturnedClass();
}
 
开发者ID:alejandro-du,项目名称:enterprise-app,代码行数:44,代码来源:CustomHbnContainer.java

示例9: getValue

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
/**
 * This method gets the value that is stored by the property. The returned object is compatible with the
 * class returned by getType().
 */
@SuppressWarnings("unchecked")
@Override
public Object getValue()
{
	logger.executionTrace();

	final Session session = sessionFactory.getCurrentSession();
	final SessionImplementor sessionImplementor = (SessionImplementor) session;

	if (!sessionFactory.getCurrentSession().contains(pojo))
		pojo = (T) session.get(entityType, (Serializable) getIdForPojo(pojo));

	if (propertyInEmbeddedKey(propertyName))
	{
		final ComponentType identifierType = (ComponentType) classMetadata.getIdentifierType();
		final String[] propertyNames = identifierType.getPropertyNames();

		for (int i = 0; i < propertyNames.length; i++)
		{
			String name = propertyNames[i];

			if (name.equals(propertyName))
			{
				final Object id = classMetadata.getIdentifier(pojo, sessionImplementor);
				return identifierType.getPropertyValue(id, i, EntityMode.POJO);
			}
		}
	}

	final Type propertyType = getPropertyType();
	final Object propertyValue = classMetadata.getPropertyValue(pojo, propertyName);

	if (!propertyType.isAssociationType())
		return propertyValue;

	if (propertyType.isCollectionType())
	{
		if (propertyValue == null)
			return null;

		final HashSet<Serializable> identifiers = new HashSet<Serializable>();
		final Collection<?> pojos = (Collection<?>) propertyValue;

		for (Object object : pojos)
		{
			if (!session.contains(object))
				object = session.merge(object);

			identifiers.add(session.getIdentifier(object));
		}

		return identifiers;
	}

	if (propertyValue == null)
		return null;

	final Class<?> propertyTypeClass = propertyType.getReturnedClass();
	final ClassMetadata metadata = sessionFactory.getClassMetadata(propertyTypeClass);
	final Serializable identifier = metadata.getIdentifier(propertyValue, sessionImplementor);

	return identifier;
}
 
开发者ID:alejandro-du,项目名称:enterprise-app,代码行数:68,代码来源:CustomHbnContainer.java

示例10: process

import org.hibernate.type.ComponentType; //导入方法依赖的package包/类
/**
 * @param request
 * @return
 * @see edu.utah.further.core.chain.AbstractRequestHandler#process(edu.utah.further.core.api.chain.ChainRequest)
 * @see http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
 */
@Override
public boolean process(final ChainRequest request)
{
	final HibernateExecReq executionReq = new HibernateExecReq(request);

	// Validate required input
	final GenericCriteria hibernateCriteria = executionReq.getResult();
	notNull(hibernateCriteria, "Expected Hibernate criteria");

	final Class<? extends PersistentEntity<?>> domainClass = executionReq
			.getRootEntity();
	final Class<? extends PersistentEntity<?>> entityClass = dao
			.getEntityClass(domainClass);

	notNull(entityClass, "Expected root entity class");

	final SessionFactory sessionFactory = executionReq.getSessionFactory();
	notNull(sessionFactory, "Expected SessionFactory");

	final ClassMetadata classMetadata = sessionFactory.getClassMetadata(entityClass);
	final String identifierName = classMetadata.getIdentifierPropertyName();
	final Type identifierType = classMetadata.getIdentifierType();

	// A hack to obtain projections out of the critieria by casting to the Hibernate
	// implementation. TODO: improve adapter to do that via interface access
	final ProjectionList projectionList = Projections.projectionList();
	final Projection existingProjection = ((CriteriaImpl) hibernateCriteria
			.getHibernateCriteria()).getProjection();

	if (existingProjection != null && !overrideExistingProjection)
	{
		return false;
	}

	if (identifierType.isComponentType())
	{
		final ComponentType componentType = (ComponentType) identifierType;
		final String[] idPropertyNames = componentType.getPropertyNames();

		// Add distinct to the first property
		projectionList.add(
				Projections.distinct(Property.forName(identifierName
						+ PROPERTY_SCOPE_CHAR + idPropertyNames[0])),
				idPropertyNames[0]);

		// Add the remaining properties to the projection list
		for (int i = 1; i < idPropertyNames.length; i++)
		{
			projectionList.add(
					Property.forName(identifierName + PROPERTY_SCOPE_CHAR
							+ idPropertyNames[i]), idPropertyNames[i]);
		}

		hibernateCriteria.setProjection(projectionList);
		hibernateCriteria.setResultTransformer(new AliasToBeanResultTransformer(
				ReflectionUtils.findField(entityClass, identifierName).getType()));
	}
	else
	{
		// 'this' required to avoid HHH-817
		projectionList.add(Projections.distinct(Property.forName(THIS_CONTEXT
				+ identifierName)));
		hibernateCriteria.setProjection(projectionList);
	}

	executionReq.setResult(hibernateCriteria);

	return false;
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:76,代码来源:HibernateDistinctIdExecutor.java


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