當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassMetadata.getPropertyTypes方法代碼示例

本文整理匯總了Java中org.hibernate.metadata.ClassMetadata.getPropertyTypes方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassMetadata.getPropertyTypes方法的具體用法?Java ClassMetadata.getPropertyTypes怎麽用?Java ClassMetadata.getPropertyTypes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.metadata.ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata.getPropertyTypes方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: copyProperties

import org.hibernate.metadata.ClassMetadata; //導入方法依賴的package包/類
/**
 * Copies the persistent properties from the source to the destination entity
 */
public void copyProperties(final Entity source, final Entity dest) {
    if (source == null || dest == null) {
        return;
    }
    final ClassMetadata metaData = getClassMetaData(source);
    final Object[] values = metaData.getPropertyValues(source, EntityMode.POJO);
    // Skip the collections
    final Type[] types = metaData.getPropertyTypes();
    for (int i = 0; i < types.length; i++) {
        final Type type = types[i];
        if (type instanceof CollectionType) {
            values[i] = null;
        }
    }
    metaData.setPropertyValues(dest, values, EntityMode.POJO);
}
 
開發者ID:crypto-coder,項目名稱:open-cyclos,代碼行數:20,代碼來源:HibernateQueryHandler.java

示例2: HibernateEntityCollection

import org.hibernate.metadata.ClassMetadata; //導入方法依賴的package包/類
/**
 * Construct a entity collection.
 *
 * @param parentMetadata parent meta data
 * @param childMetadata child meta data
 * @param parent parent object
 * @param objects child objects
 */
public HibernateEntityCollection(ClassMetadata parentMetadata, ClassMetadata childMetadata, Object parent,
		Collection<?> objects) {
	this.objects = objects;
	int i = 0;
	for (Type type : childMetadata.getPropertyTypes()) {
		if (type instanceof ManyToOneType) {
			ManyToOneType mto = (ManyToOneType) type;
			if (mto.getAssociatedEntityName().equals(parentMetadata.getEntityName())) {
				parentName = childMetadata.getPropertyNames()[i];
			}
		}
		i++;
	}
	this.metadata = childMetadata;
	this.parent = parent;
}
 
開發者ID:geomajas,項目名稱:geomajas-project-server,代碼行數:25,代碼來源:HibernateEntityMapper.java

示例3: toString

import org.hibernate.metadata.ClassMetadata; //導入方法依賴的package包/類
/**
 * @param entity an actual entity object, not a proxy!
 */
public String toString(Object entity, EntityMode entityMode) throws HibernateException {

	// todo : this call will not work for anything other than pojos!
	ClassMetadata cm = factory.getClassMetadata( entity.getClass() );

	if ( cm==null ) return entity.getClass().getName();

	Map result = new HashMap();

	if ( cm.hasIdentifierProperty() ) {
		result.put(
			cm.getIdentifierPropertyName(),
			cm.getIdentifierType().toLoggableString( cm.getIdentifier( entity, entityMode ), factory )
		);
	}

	Type[] types = cm.getPropertyTypes();
	String[] names = cm.getPropertyNames();
	Object[] values = cm.getPropertyValues( entity, entityMode );
	for ( int i=0; i<types.length; i++ ) {
		if ( !names[i].startsWith("_") ) {
			String strValue = values[i]==LazyPropertyInitializer.UNFETCHED_PROPERTY ?
				values[i].toString() :
				types[i].toLoggableString( values[i], factory );
			result.put( names[i], strValue );
		}
	}
	return cm.getEntityName() + result.toString();
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:33,代碼來源:Printer.java

示例4: processRelationships

import org.hibernate.metadata.ClassMetadata; //導入方法依賴的package包/類
/**
 * Connect the related entities based on the foreign key values.
 * Note that this may cause related entities to be loaded from the DB if they are not already in the session.
 * @param entityInfo Entity that will be saved
 * @param meta Metadata about the entity type
 */
private void processRelationships(EntityInfo entityInfo, ClassMetadata meta) {
    addToGraph(entityInfo, null); // make sure every entity is in the graph
    String[] propNames = meta.getPropertyNames();
    Type[] propTypes = meta.getPropertyTypes();

    Type propType = meta.getIdentifierType();
    if (propType != null) {
        processRelationship(meta.getIdentifierPropertyName(), propType, entityInfo, meta);
    }

    for (int i = 0; i < propNames.length; i++) {
        processRelationship(propNames[i], propTypes[i], entityInfo, meta);
    }
}
 
開發者ID:Breeze,項目名稱:breeze.server.java,代碼行數:21,代碼來源:RelationshipFixer.java

示例5: resolveReferences

import org.hibernate.metadata.ClassMetadata; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void resolveReferences(final Entity entity) {
    final ClassMetadata meta = getClassMetaData(entity);
    final String[] names = meta.getPropertyNames();
    final Type[] types = meta.getPropertyTypes();
    for (int i = 0; i < types.length; i++) {
        final Type type = types[i];
        final String name = names[i];
        if (type instanceof EntityType) {
            // Properties that are relationships to other entities
            Entity rel = PropertyHelper.get(entity, name);
            if (rel instanceof EntityReference) {
                rel = getHibernateTemplate().load(EntityHelper.getRealClass(rel), rel.getId());
                PropertyHelper.set(entity, name, rel);
            }
        } else if (type instanceof CollectionType && !(type instanceof MapType)) {
            // Properties that are collections of other entities
            final Collection<?> current = PropertyHelper.get(entity, name);
            if (current != null && !(current instanceof PersistentCollection)) {
                // We must check that the collection is made of entities, since Hibernate supports collections os values
                boolean isEntityCollection = true;
                final Collection<Entity> resolved = ClassHelper.instantiate(current.getClass());
                for (final Object object : current) {
                    if (object != null && !(object instanceof Entity)) {
                        isEntityCollection = false;
                        break;
                    }
                    Entity e = (Entity) object;
                    if (object instanceof EntityReference) {
                        e = getHibernateTemplate().load(EntityHelper.getRealClass(e), e.getId());
                    }
                    resolved.add(e);
                }
                if (isEntityCollection) {
                    PropertyHelper.set(entity, name, resolved);
                }
            }
        }
    }
}
 
開發者ID:crypto-coder,項目名稱:open-cyclos,代碼行數:41,代碼來源:HibernateQueryHandler.java


注:本文中的org.hibernate.metadata.ClassMetadata.getPropertyTypes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。