Example usage for org.hibernate.mapping PersistentClass getPropertyClosureIterator

List of usage examples for org.hibernate.mapping PersistentClass getPropertyClosureIterator

Introduction

In this page you can find the example usage for org.hibernate.mapping PersistentClass getPropertyClosureIterator.

Prototype

public abstract Iterator getPropertyClosureIterator();

Source Link

Usage

From source file:com.googlecode.hibernate.audit.listener.AuditSessionFactoryObserver.java

License:Open Source License

private AuditType initializeEntityAuditType(Session session, String entityName, boolean initializeProperties) {
    PersistentClass classMapping = auditConfiguration.getMetadata().getEntityBinding(entityName);
    String auditTypeClassName = auditConfiguration.getExtensionManager().getAuditableInformationProvider()
            .getAuditTypeClassName(auditConfiguration.getMetadata(), entityName);

    AuditType auditType = HibernateAudit.getAuditType(session, auditTypeClassName);
    if (auditType == null) {
        auditType = new AuditType();
        auditType.setClassName(auditTypeClassName);
        auditType.setLabel(entityName);// ww w .  ja  v  a  2  s .c om
        auditType.setType(AuditType.ENTITY_TYPE);

        session.save(auditType);
        updateMetaModel(session);
    }

    if (initializeProperties) {
        Property identifierProperty = classMapping.getIdentifierProperty();
        if (identifierProperty != null) {
            initializeAuditField(session, auditTypeClassName, auditType, identifierProperty.getName(),
                    identifierProperty.getType());
        }

        for (Iterator propertyIterator = classMapping.getPropertyClosureIterator(); propertyIterator
                .hasNext();) {
            Property property = (Property) propertyIterator.next();
            initializeAuditField(session, auditTypeClassName, auditType, property.getName(),
                    property.getType());
        }
    }
    return auditType;
}

From source file:test.hibernate.ExecutionEnvironment.java

License:Open Source License

@SuppressWarnings("unchecked")
private void applyCacheSettings(Configuration configuration) {
    if (settings.getCacheConcurrencyStrategy() != null) {
        Iterator iter = configuration.getClassMappings();
        while (iter.hasNext()) {
            PersistentClass clazz = (PersistentClass) iter.next();
            Iterator props = clazz.getPropertyClosureIterator();
            boolean hasLob = false;
            while (props.hasNext()) {
                Property prop = (Property) props.next();
                if (prop.getValue().isSimpleValue()) {
                    String type = ((SimpleValue) prop.getValue()).getTypeName();
                    if ("blob".equals(type) || "clob".equals(type)) {
                        hasLob = true;// ww  w  . j  a v a  2  s.c om
                    }
                    if (Blob.class.getName().equals(type) || Clob.class.getName().equals(type)) {
                        hasLob = true;
                    }
                }
            }
            if (!hasLob && !clazz.isInherited() && settings.overrideCacheStrategy()) {
                configuration.setCacheConcurrencyStrategy(clazz.getEntityName(),
                        settings.getCacheConcurrencyStrategy());
            }
        }
        iter = configuration.getCollectionMappings();
        while (iter.hasNext()) {
            Collection coll = (Collection) iter.next();
            configuration.setCollectionCacheConcurrencyStrategy(coll.getRole(),
                    settings.getCacheConcurrencyStrategy());
        }
    }
}