Example usage for org.hibernate.tuple.entity EntityMetamodel getTuplizer

List of usage examples for org.hibernate.tuple.entity EntityMetamodel getTuplizer

Introduction

In this page you can find the example usage for org.hibernate.tuple.entity EntityMetamodel getTuplizer.

Prototype

public EntityTuplizer getTuplizer() 

Source Link

Usage

From source file:org.jboss.tools.hibernate4_0.console.EntityPropertySource.java

License:Open Source License

public Object getPropertyValue(Object id) {
    Object propertyValue;/*w w w.j av  a 2 s  .c  om*/

    if (id.equals(classMetadata.getIdentifierPropertyName())) {
        propertyValue = classMetadata.getIdentifier(reflectedObject, (SessionImplementor) currentSession);
    } else {
        try {
            propertyValue = classMetadata.getPropertyValue(reflectedObject, (String) id);
        } catch (HibernateException he) {
            propertyValue = HibernateConsoleMessages.EntityPropertySource_unable_to_resolve_property;
            if (classMetadata instanceof AbstractEntityPersister) {
                AbstractEntityPersister aep = (AbstractEntityPersister) classMetadata;
                EntityMetamodel emm = aep.getEntityMetamodel();
                if (emm != null) {
                    Integer idx = emm.getPropertyIndexOrNull((String) id);
                    if (idx != null) {
                        propertyValue = emm.getTuplizer().getPropertyValue(reflectedObject, idx);
                    }
                }
            }
        }
    }

    if (propertyValue instanceof Collection<?>) {
        CollectionMetadata collectionMetadata = currentSession.getSessionFactory()
                .getCollectionMetadata(classMetadata.getEntityName() + "." + id); //$NON-NLS-1$
        if (collectionMetadata != null) {
            propertyValue = new CollectionPropertySource((Collection<?>) propertyValue);
        }
    }
    return propertyValue;
}