List of usage examples for org.hibernate.cfg AccessType getAccessStrategy
public static AccessType getAccessStrategy(javax.persistence.AccessType type)
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 w ww. ja v a 2 s .co 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); } } }