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


Java Property.getColumnIterator方法代码示例

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


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

示例1: matchColumnsByProperty

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
private static void matchColumnsByProperty(Property property, Map<Column, Set<Property>> columnsToProperty) {
		if ( property == null ) return;
		if ( "noop".equals( property.getPropertyAccessorName() )
				|| "embedded".equals( property.getPropertyAccessorName() ) ) {
			return;
		}
// FIXME cannot use subproperties becasue the caller needs top level properties
//		if ( property.isComposite() ) {
//			Iterator subProperties = ( (Component) property.getValue() ).getPropertyIterator();
//			while ( subProperties.hasNext() ) {
//				matchColumnsByProperty( (Property) subProperties.next(), columnsToProperty );
//			}
//		}
		else {
			Iterator columnIt = property.getColumnIterator();
			while ( columnIt.hasNext() ) {
				Object column = columnIt.next(); //can be a Formula so we don't cast
				//noinspection SuspiciousMethodCalls
				if ( columnsToProperty.containsKey( column ) ) {
					columnsToProperty.get( column ).add( property );
				}
			}
		}
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:BinderHelper.java

示例2: fixSchemaInFormulas

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
public static void fixSchemaInFormulas(Configuration cfg) {
	cfg.buildMappings();
    String schema = cfg.getProperty("default_schema"); 
    if (schema!=null) {
        for (Iterator i=cfg.getClassMappings();i.hasNext();) {
            PersistentClass pc = (PersistentClass)i.next();
            for (Iterator j=pc.getPropertyIterator();j.hasNext();) {
                Property p = (Property)j.next();
                for (Iterator k=p.getColumnIterator();k.hasNext();) {
                    Selectable c = (Selectable)k.next();
                    if (c instanceof Formula) {
                        Formula f = (Formula)c;
                        if (f.getFormula()!=null && f.getFormula().indexOf("%SCHEMA%")>=0) {
                            f.setFormula(f.getFormula().replaceAll("%SCHEMA%", schema));
                            sLog.debug("Schema updated in "+pc.getClassName()+"."+p.getName()+" to "+f.getFormula());
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:23,代码来源:HibernateUtil.java

示例3: getColumnNames

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected String[] getColumnNames( Class peristentClass, String[] includedFields )
        throws MappingException
{
    Collection columns = new ArrayList();
    for ( int i = 0; i < includedFields.length; i++ )
    {
        String propertyName = includedFields[i];
        Property property = getMapping( peristentClass ).getProperty( propertyName );

        for ( Iterator it = property.getColumnIterator(); it.hasNext(); )
        {
            Column col = ( Column ) it.next();
            columns.add( col.getName() );
        }
    }
    return ( String[] ) columns.toArray( new String[columns.size()] );
}
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:19,代码来源:AbstractDBUnitHibernateMemoryTest.java

示例4: testEntityToDatabaseBindingMetadata

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
@Test
public void testEntityToDatabaseBindingMetadata() {
    Metadata metadata = MetadataExtractorIntegrator.INSTANCE.getMetadata();

    for ( PersistentClass persistentClass : metadata.getEntityBindings()) {
        Table table = persistentClass.getTable();
        LOGGER.info( "Entity: {} is mapped to table: {}",
                     persistentClass.getClassName(),
                     table.getName()
        );

        for(Iterator propertyIterator =
                persistentClass.getPropertyIterator(); propertyIterator.hasNext(); ) {
            Property property = (Property) propertyIterator.next();
            for(Iterator columnIterator =
                    property.getColumnIterator(); columnIterator.hasNext(); ) {
                Column column = (Column) columnIterator.next();
                LOGGER.info( "Property: {} is mapped on table column: {} of type: {}",
                             property.getName(),
                             column.getName(),
                             column.getSqlType()
                );
            }
        }
    }
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:27,代码来源:MetadataTest.java

示例5: applyNotNull

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
private static boolean applyNotNull(Property property, ConstraintDescriptor<?> descriptor) {
	boolean hasNotNull = false;
	if ( NotNull.class.equals( descriptor.getAnnotation().annotationType() ) ) {
		// single table inheritance should not be forced to null due to shared state
		if ( !( property.getPersistentClass() instanceof SingleTableSubclass ) ) {
			//composite should not add not-null on all columns
			if ( !property.isComposite() ) {
				final Iterator<Selectable> iter = property.getColumnIterator();
				while ( iter.hasNext() ) {
					final Selectable selectable = iter.next();
					if ( Column.class.isInstance( selectable ) ) {
						Column.class.cast( selectable ).setNullable( false );
					}
					else {
						LOG.debugf(
								"@NotNull was applied to attribute [%s] which is defined (at least partially) " +
										"by formula(s); formula portions will be skipped",
								property.getName()
						);
					}
				}
			}
		}
		hasNotNull = true;
	}
	return hasNotNull;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:TypeSafeActivator.java

示例6: internalInitSubclassPropertyAliasesMap

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
private void internalInitSubclassPropertyAliasesMap(String path, Iterator propertyIterator) {
	while ( propertyIterator.hasNext() ) {

		Property prop = ( Property ) propertyIterator.next();
		String propname = path == null ? prop.getName() : path + "." + prop.getName();
		if ( prop.isComposite() ) {
			Component component = ( Component ) prop.getValue();
			Iterator compProps = component.getPropertyIterator();
			internalInitSubclassPropertyAliasesMap( propname, compProps );
		}
		else {
			String[] aliases = new String[prop.getColumnSpan()];
			String[] cols = new String[prop.getColumnSpan()];
			Iterator colIter = prop.getColumnIterator();
			int l = 0;
			while ( colIter.hasNext() ) {
				Selectable thing = ( Selectable ) colIter.next();
				aliases[l] = thing.getAlias( getFactory().getDialect(), prop.getValue().getTable() );
				cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas?
				l++;
			}

			subclassPropertyAliases.put( propname, aliases );
			subclassPropertyColumnNames.put( propname, cols );
		}
	}

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

示例7: getAttributeForTabCol

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
private String getAttributeForTabCol(String entity, String col)
{
	if (entity == null || col == null)
		return null;
	
	PersistentClass cls = Registry.getInstance().getConfiguration().getClassMapping(entity);
	if (cls != null)
	{
		Iterator it = cls.getPropertyIterator();
		while (it.hasNext())
		{
			Property prop = (Property) it.next();
			Iterator it2 = prop.getColumnIterator();
			while (it2.hasNext())
			{
				Column col2 = (Column) it2.next();
				if (col2 != null && col2.getName().equals(col))
					return prop.getName();
			}
		
		}
	}
	
	// Recursively get super classes in case not found in at this level
	if (cls.getSuperclass() != null)
	{
		return (getAttributeForTabCol(cls.getSuperclass().getClassName(), col));
	}
	return null;
}
 
开发者ID:oopcell,项目名称:AvoinApotti,代码行数:31,代码来源:PatientMergerServlet.java

示例8: getColumnNames

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected String[] getColumnNames(Class<?> peristentClass, String[] includedFields) throws MappingException {
    Collection<String> columns = new ArrayList<String>();
    for (int i = 0; i < includedFields.length; i++) {
        String propertyName = includedFields[i];
        Property property = getMapping(peristentClass).getProperty(propertyName);

        for (Iterator<Column> it = property.getColumnIterator(); it.hasNext(); ) {
            Column col = it.next();
            columns.add(col.getName());
        }
    }
    return columns.toArray(new String[columns.size()]);
}
 
开发者ID:testIT-LivingDoc,项目名称:livingdoc-confluence,代码行数:15,代码来源:AbstractDBUnitHibernateMemoryTest.java

示例9: getColumnName

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
/**
 * Retrieves the column name for the given PersistentClass and fieldName.
 *
 * @param pc
 * @param fieldName
 * @return columnName
 */
private static String getColumnName(PersistentClass pc, String fieldName) {
    if (pc == null) {
        return null;
    }

    String columnName = null;
    Property property = pc.getProperty(fieldName);
    for (Iterator<?> it3 = property.getColumnIterator(); it3.hasNext();) {
        Object o = it3.next();
        if (!(o instanceof Column)) {
            LOG.debug("Skipping non-column (probably a formula");
            continue;
        }
        Column column = (Column) o;
        columnName = column.getName();
        break;
    }
    if (columnName == null) {
        try {
            columnName = getColumnName(pc.getSuperclass(), fieldName);
        } catch (MappingException e) {
            // in this case the annotation / mapping info was at the current class and not the base class
            // but for some reason the column name could not be determined.
            // This will happen when a subclass of an entity uses a joined subclass.
            // in this case just set column Name to null and let the caller default to the property name.
            columnName = null;
        }
    }

    return columnName;
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:39,代码来源:CaArrayAuditLogInterceptor.java

示例10: extractColumnValues

import org.hibernate.mapping.Property; //导入方法依赖的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

示例11: HibernateEntityTableMappingImpl

import org.hibernate.mapping.Property; //导入方法依赖的package包/类
public HibernateEntityTableMappingImpl(Configuration configuration) {
    if(configuration==null){
        throw new IllegalArgumentException("Null hibernate configuration");
    }
    LOG.debug("Found hibernate configuration.");

    this.configuration = configuration;
    HibernateHelper.registerConfiguration(configuration);

    //init entityTableMap
    Iterator<PersistentClass> it = configuration.getClassMappings();
    while(it.hasNext()){
        PersistentClass pClass = it.next();

        EntityMapping entityMapping = new EntityMapping();
        entityMapping.setName(pClass.getEntityName());

        Iterator<Property> iterator = pClass.getPropertyIterator();
        while(iterator.hasNext()){
            Property p = iterator.next();
            Getter getter = p.getGetter(pClass.getMappedClass());
            Member member = getter.getMember();
            //ignore the collection field
            if(Collection.class.isAssignableFrom(getter.getReturnType())){
                LOG.trace("ignore collection member :{}",member);
                continue;
            }

            Iterator<Selectable> colIt = p.getColumnIterator();
            Selectable selectable = colIt.next();
            if(selectable instanceof Column){
                Column col = (Column)selectable;
                String fieldName = ObjectUtils.getterField(member.getName());
                entityMapping.getFieldColumnMap().put(fieldName, col.getName());

                EntityField entityField = new EntityField(fieldName,getter.getReturnType().getName());
                entityMapping.getFieldMap().put(fieldName,entityField);
            }
        }
        entityTableMap.put(entityMapping.getName(), pClass.getTable().getName());
        entityMappingMap.put(entityMapping.getName(),entityMapping);

    }

    LOG.debug("{} entities detected",entityMappingMap.size());
}
 
开发者ID:yaohuiwu,项目名称:CAM,代码行数:47,代码来源:HibernateEntityTableMappingImpl.java


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