Example usage for org.hibernate.type CompositeType getPropertyValues

List of usage examples for org.hibernate.type CompositeType getPropertyValues

Introduction

In this page you can find the example usage for org.hibernate.type CompositeType getPropertyValues.

Prototype

Object[] getPropertyValues(Object component, EntityMode entityMode) throws HibernateException;

Source Link

Document

Extract the values of the component properties from the given component instance without access to the session.

Usage

From source file:edu.northwestern.bioinformatics.studycalendar.service.auditing.AuditEventFactory.java

License:BSD License

private Object[] getComponentState(CompositeType propertyType, Object state) {
    return state == null ? null : propertyType.getPropertyValues(state, ENTITY_MODE);
}

From source file:gov.nih.nci.cabig.ctms.audit.AuditInterceptorImpl.java

License:BSD License

private List<DataAuditEventValue> decomposeComponent(final CompositeType propertyType,
        final String propertyName, final Object previousState, final Object currentState) {
    Object[] componentPrevState = previousState == null ? null
            : propertyType.getPropertyValues(previousState, ENTITY_MODE);
    Object[] componentCurState = currentState == null ? null
            : propertyType.getPropertyValues(currentState, ENTITY_MODE);
    List<Integer> differences = findDifferences(componentCurState, componentPrevState, null);
    List<DataAuditEventValue> values = new ArrayList<DataAuditEventValue>(differences.size());
    for (Integer index : differences) {
        String compPropertyName = propertyName + '.' + propertyType.getPropertyNames()[index];
        values.add(new DataAuditEventValue(compPropertyName,
                previousState == null ? null : scalarAuditableValue(componentPrevState[index]),
                currentState == null ? null : scalarAuditableValue(componentCurState[index])));
    }//from  w  w  w  .  j a va2 s  . c  o m
    return values;
}

From source file:org.eulerframework.web.core.extend.hibernate5.InExpressionX.java

License:Apache License

@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) {
    final ArrayList<TypedValue> list = new ArrayList<TypedValue>();
    final Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
    if (type.isComponentType()) {
        final CompositeType compositeType = (CompositeType) type;
        final Type[] subTypes = compositeType.getSubtypes();
        for (Object value : values) {
            for (int i = 0; i < subTypes.length; i++) {
                final Object subValue = value == null ? null
                        : compositeType.getPropertyValues(value, EntityMode.POJO)[i];
                list.add(new TypedValue(subTypes[i], subValue));
            }/* www . j ava  2s  . c o m*/
        }
    } else {
        for (Object value : values) {
            list.add(new TypedValue(type, value));
        }
    }

    return list.toArray(new TypedValue[list.size()]);
}