org.hibernate.mapping.Property Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate Show documentation
Show all versions of hibernate Show documentation
Relational Persistence for Java
//$Id: Property.java 10247 2006-08-11 18:49:33Z [email protected] $
package org.hibernate.mapping;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.hibernate.MappingException;
import org.hibernate.PropertyNotFoundException;
import org.hibernate.EntityMode;
import org.hibernate.engine.CascadeStyle;
import org.hibernate.engine.Mapping;
import org.hibernate.property.Getter;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.property.PropertyAccessorFactory;
import org.hibernate.property.Setter;
import org.hibernate.type.AbstractComponentType;
import org.hibernate.type.Type;
import org.hibernate.util.ArrayHelper;
/**
* Represents a property as part of an entity or a component.
*
* @author Gavin King
*/
public class Property implements Serializable, MetaAttributable {
private String name;
private Value value;
private String cascade;
private boolean updateable = true;
private boolean insertable = true;
private boolean selectable = true;
private boolean optimisticLocked = true;
private PropertyGeneration generation = PropertyGeneration.NEVER;
private String propertyAccessorName;
private boolean lazy;
private boolean optional;
private String nodeName;
private java.util.Map metaAttributes;
private PersistentClass persistentClass;
private boolean naturalIdentifier;
public boolean isBackRef() {
return false;
}
public Type getType() throws MappingException {
return value.getType();
}
public int getColumnSpan() {
return value.getColumnSpan();
}
public Iterator getColumnIterator() {
return value.getColumnIterator();
}
public String getName() {
return name;
}
public boolean isComposite() {
return value instanceof Component;
}
public Value getValue() {
return value;
}
public boolean isPrimitive(Class clazz) {
return getGetter(clazz).getReturnType().isPrimitive();
}
public CascadeStyle getCascadeStyle() throws MappingException {
Type type = value.getType();
if ( type.isComponentType() && !type.isAnyType() ) {
AbstractComponentType actype = (AbstractComponentType) type;
int length = actype.getSubtypes().length;
for ( int i=0; i