| Method from org.hibernate.cfg.annotations.PropertyBinder Detail: |
public Property bind() {
validateBind();
if ( log.isDebugEnabled() ) {
log.debug( "binding property " + name + " with lazy=" + lazy );
}
String containerClassName = holder == null ?
null :
holder.getClassName();
SimpleValueBinder value = new SimpleValueBinder();
value.setMappings( mappings );
value.setPropertyName( name );
value.setReturnedClassName( returnedClassName );
value.setColumns( columns );
value.setPersistentClassName( containerClassName );
value.setType( property, returnedClass );
value.setMappings( mappings );
SimpleValue propertyValue = value.make();
setValue( propertyValue );
Property prop = make();
holder.addProperty( prop, columns );
return prop;
}
|
public Property make() {
validateMake();
log.debug( "Building property " + name );
Property prop = new Property();
prop.setName( name );
prop.setNodeName( name );
prop.setValue( value );
prop.setLazy( lazy );
prop.setCascade( cascade );
prop.setPropertyAccessorName( propertyAccessorName );
Generated ann = property != null ?
property.getAnnotation( Generated.class ) :
null;
GenerationTime generated = ann != null ?
ann.value() :
null;
if ( generated != null ) {
if ( !GenerationTime.NEVER.equals( generated ) ) {
if ( property.isAnnotationPresent( javax.persistence.Version.class )
&& GenerationTime.INSERT.equals( generated ) ) {
throw new AnnotationException( "@Generated(INSERT) on a @Version property not allowed, use ALWAYS: "
+ StringHelper.qualify( holder.getPath(), name ) );
}
insertable = false;
if ( GenerationTime.ALWAYS.equals( generated ) ) {
updatable = false;
}
prop.setGeneration( PropertyGeneration.parse( generated.toString().toLowerCase() ) );
}
}
prop.setInsertable( insertable );
prop.setUpdateable( updatable );
OptimisticLock lockAnn = property != null ?
property.getAnnotation( OptimisticLock.class ) :
null;
if ( lockAnn != null) {
prop.setOptimisticLocked( ! lockAnn.excluded() );
//TODO this should go to the core as a mapping validation checking
if ( lockAnn.excluded() && (
property.isAnnotationPresent( javax.persistence.Version.class )
|| property.isAnnotationPresent( Id.class )
|| property.isAnnotationPresent( EmbeddedId.class ) ) ) {
throw new AnnotationException("@OptimisticLock.exclude=true incompatible with @Id, @EmbeddedId and @Version: "
+ StringHelper.qualify( holder.getPath(), name ) );
}
}
log.trace( "Cascading " + name + " with " + cascade );
return prop;
}
|
public void setCascade(String cascadeStrategy) {
this.cascade = cascadeStrategy;
}
|
public void setColumns(Ejb3Column[] columns) {
insertable = columns[0].isInsertable();
updatable = columns[0].isUpdatable();
//concsistency is checked later when we know the proeprty name
this.columns = columns;
}
|
public void setHolder(PropertyHolder holder) {
this.holder = holder;
}
|
public void setInsertable(boolean insertable) {
this.insertable = insertable;
}
|
public void setLazy(boolean lazy) {
this.lazy = lazy;
}
|
public void setMappings(ExtendedMappings mappings) {
this.mappings = mappings;
}
|
public void setName(String name) {
this.name = name;
}
|
public void setProperty(XProperty property) {
this.property = property;
}
|
public void setPropertyAccessorName(String propertyAccessorName) {
this.propertyAccessorName = propertyAccessorName;
}
|
public void setReturnedClass(XClass returnedClass) {
this.returnedClass = returnedClass;
}
|
public void setReturnedClassName(String returnedClassName) {
this.returnedClassName = returnedClassName;
}
|
public void setUpdatable(boolean updatable) {
this.updatable = updatable;
}
|
public void setValue(Value value) {
this.value = value;
}
|