FileDocCategorySizeDatePackage
Property.javaAPI DocHibernate 3.2.57792Fri Aug 11 13:49:34 BST 2006org.hibernate.mapping

Property

public class Property extends Object implements Serializable, MetaAttributable
Represents a property as part of an entity or a component.
author
Gavin King

Fields Summary
private String
name
private Value
value
private String
cascade
private boolean
updateable
private boolean
insertable
private boolean
selectable
private boolean
optimisticLocked
private PropertyGeneration
generation
private String
propertyAccessorName
private boolean
lazy
private boolean
optional
private String
nodeName
private Map
metaAttributes
private PersistentClass
persistentClass
private boolean
naturalIdentifier
Constructors Summary
Methods Summary
public java.lang.StringgetAccessorPropertyName(org.hibernate.EntityMode mode)

		if ( mode == EntityMode.DOM4J ) {
			return nodeName;
		}
		else {
			return getName();
		}
	
public java.lang.StringgetCascade()

		return cascade;
	
public org.hibernate.engine.CascadeStylegetCascadeStyle()

		Type type = value.getType();
		if ( type.isComponentType() && !type.isAnyType() ) {
			AbstractComponentType actype = (AbstractComponentType) type;
			int length = actype.getSubtypes().length;
			for ( int i=0; i<length; i++ ) {
				if ( actype.getCascadeStyle(i)!=CascadeStyle.NONE ) return CascadeStyle.ALL;
			}
			return CascadeStyle.NONE;
		}
		else if ( cascade==null || cascade.equals("none") ) {
			return CascadeStyle.NONE;
		}
		else {
			StringTokenizer tokens = new StringTokenizer(cascade, ", ");
			CascadeStyle[] styles = new CascadeStyle[ tokens.countTokens() ] ;
			int i=0;
			while ( tokens.hasMoreTokens() ) {
				styles[i++] = CascadeStyle.getCascadeStyle( tokens.nextToken() );
			}
			return new CascadeStyle.MultipleCascadeStyle(styles);
		}
	
public java.util.IteratorgetColumnIterator()

		return value.getColumnIterator();
	
public intgetColumnSpan()

		return value.getColumnSpan();
	
public PropertyGenerationgetGeneration()

        return generation;
    
public org.hibernate.property.GettergetGetter(java.lang.Class clazz)

		return getPropertyAccessor(clazz).getGetter(clazz, name);
	
public MetaAttributegetMetaAttribute(java.lang.String attributeName)

		return metaAttributes==null?null:(MetaAttribute) metaAttributes.get(attributeName);
	
public java.util.MapgetMetaAttributes()

		return metaAttributes;
	
public java.lang.StringgetName()

		return name;
	
public java.lang.StringgetNodeName()

		return nodeName;
	
public PersistentClassgetPersistentClass()

		return persistentClass;
	
public org.hibernate.property.PropertyAccessorgetPropertyAccessor(java.lang.Class clazz)

		return PropertyAccessorFactory.getPropertyAccessor( clazz, getPropertyAccessorName() );
	
public java.lang.StringgetPropertyAccessorName()

		return propertyAccessorName;
	
public org.hibernate.property.SettergetSetter(java.lang.Class clazz)

		return getPropertyAccessor(clazz).getSetter(clazz, name);
	
public org.hibernate.type.TypegetType()

		return value.getType();
	
public ValuegetValue()

		return value;
	
public booleanisBackRef()

	
	   
		return false;
	
public booleanisBasicPropertyAccessor()

		return propertyAccessorName==null || "property".equals(propertyAccessorName);
	
public booleanisComposite()

		return value instanceof Component;
	
public booleanisInsertable()

		// if the property mapping consists of all formulas, 
		// make it insertable
		final boolean[] columnInsertability = value.getColumnInsertability();
		return insertable && (
				columnInsertability.length==0 ||
				!ArrayHelper.isAllFalse(columnInsertability)
			);
	
public booleanisLazy()

		if ( value instanceof ToOne ) {
			// both many-to-one and one-to-one are represented as a
			// Property.  EntityPersister is relying on this value to
			// determine "lazy fetch groups" in terms of field-level
			// interception.  So we need to make sure that we return
			// true here for the case of many-to-one and one-to-one
			// with lazy="no-proxy"
			//
			// * impl note - lazy="no-proxy" currently forces both
			// lazy and unwrap to be set to true.  The other case we
			// are extremely interested in here is that of lazy="proxy"
			// where lazy is set to true, but unwrap is set to false.
			// thus we use both here under the assumption that this
			// return is really only ever used during persister
			// construction to determine the lazy property/field fetch
			// groupings.  If that assertion changes then this check
			// needs to change as well.  Partially, this is an issue with
			// the overloading of the term "lazy" here...
			ToOne toOneValue = ( ToOne ) value;
			return toOneValue.isLazy() && toOneValue.isUnwrapProxy();
		}
		return lazy;
	
public booleanisNaturalIdentifier()

		return naturalIdentifier;
	
booleanisNullable()
Approximate!

		return value==null || value.isNullable();
	
public booleanisOptimisticLocked()

		return optimisticLocked;
	
public booleanisOptional()

		return optional || isNullable();
	
public booleanisPrimitive(java.lang.Class clazz)

		return getGetter(clazz).getReturnType().isPrimitive();
	
public booleanisSelectable()

		return selectable;
	
public booleanisUpdateable()

		// if the property mapping consists of all formulas, 
		// make it non-updateable
		final boolean[] columnUpdateability = value.getColumnUpdateability();
		return updateable && ( 
				//columnUpdateability.length==0 ||
				!ArrayHelper.isAllFalse(columnUpdateability)
			);
	
public booleanisValid(org.hibernate.engine.Mapping mapping)

		return getValue().isValid(mapping);
	
public voidsetCascade(java.lang.String cascade)

		this.cascade = cascade;
	
public voidsetGeneration(PropertyGeneration generation)

        this.generation = generation;
    
public voidsetInsertable(boolean insertable)

		this.insertable = insertable;
	
public voidsetLazy(boolean lazy)

		this.lazy=lazy;
	
public voidsetMetaAttributes(java.util.Map metas)

		this.metaAttributes = metas;
	
public voidsetName(java.lang.String name)

		this.name = name==null ? null : name.intern();
	
public voidsetNaturalIdentifier(boolean naturalIdentifier)

		this.naturalIdentifier = naturalIdentifier;
	
public voidsetNodeName(java.lang.String nodeName)

		this.nodeName = nodeName;
	
public voidsetOptimisticLocked(boolean optimisticLocked)

		this.optimisticLocked = optimisticLocked;
	
public voidsetOptional(boolean optional)

		this.optional = optional;
	
public voidsetPersistentClass(PersistentClass persistentClass)

		this.persistentClass = persistentClass;
	
public voidsetPropertyAccessorName(java.lang.String string)

		propertyAccessorName = string;
	
public voidsetSelectable(boolean selectable)

		this.selectable = selectable;
	
public voidsetUpdateable(boolean mutable)

		this.updateable = mutable;
	
public voidsetValue(Value value)

		this.value = value;
	
public java.lang.StringtoString()

		return getClass().getName() + '(" + name + ')";