Example usage for org.hibernate.cfg AccessType getType

List of usage examples for org.hibernate.cfg AccessType getType

Introduction

In this page you can find the example usage for org.hibernate.cfg AccessType getType.

Prototype

public String getType() 

Source Link

Document

Retrieves the external name for this access type

Usage

From source file:org.grails.orm.hibernate.cfg.GrailsDomainBinder.java

License:Apache License

/**
 * Binds a property to Hibernate runtime meta model. Deals with cascade strategy based on the Grails domain model
 *
 * @param grailsProperty The grails property instance
 * @param prop           The Hibernate property
 * @param mappings       The Hibernate mappings
 *//*from  www .  ja v  a2s .c  o m*/
protected void bindProperty(PersistentProperty grailsProperty, Property prop,
        InFlightMetadataCollector mappings) {
    // set the property name
    prop.setName(grailsProperty.getName());
    if (isBidirectionalManyToOneWithListMapping(grailsProperty, prop)) {
        prop.setInsertable(false);
        prop.setUpdateable(false);
    } else {
        prop.setInsertable(getInsertableness(grailsProperty));
        prop.setUpdateable(getUpdateableness(grailsProperty));
    }

    AccessType accessType = AccessType
            .getAccessStrategy(grailsProperty.getMapping().getMappedForm().getAccessType());
    prop.setPropertyAccessorName(accessType.getType());
    prop.setOptional(grailsProperty.isNullable());

    setCascadeBehaviour(grailsProperty, prop);

    // lazy to true
    final boolean isToOne = grailsProperty instanceof ToOne;
    PersistentEntity propertyOwner = grailsProperty.getOwner();
    boolean isLazyable = isToOne
            || !(grailsProperty instanceof Association) && !grailsProperty.equals(propertyOwner.getIdentity());

    if (isLazyable) {
        final boolean isLazy = getLaziness(grailsProperty);
        prop.setLazy(isLazy);

        if (isLazy && isToOne
                && !(PersistentAttributeInterceptable.class.isAssignableFrom(propertyOwner.getJavaClass()))) {
            handleLazyProxy(propertyOwner, grailsProperty);
        }
    }
}