Search in sources :

Example 1 with ClassPropertyFetcher

use of org.grails.datastore.mapping.reflect.ClassPropertyFetcher in project grails-core by grails.

the class DomainClassMarshaller method asShortObject.

protected void asShortObject(Object refObj, XML xml, GrailsDomainClassProperty idProperty, GrailsDomainClass referencedDomainClass) throws ConverterException {
    Object idValue;
    if (proxyHandler instanceof EntityProxyHandler) {
        idValue = ((EntityProxyHandler) proxyHandler).getProxyIdentifier(refObj);
        if (idValue == null) {
            ClassPropertyFetcher propertyFetcher = ClassPropertyFetcher.forClass(refObj.getClass());
            idValue = propertyFetcher.getPropertyValue(refObj, idProperty.getName());
        }
    } else {
        ClassPropertyFetcher propertyFetcher = ClassPropertyFetcher.forClass(refObj.getClass());
        idValue = propertyFetcher.getPropertyValue(refObj, idProperty.getName());
    }
    xml.attribute(GrailsDomainClassProperty.IDENTITY, String.valueOf(idValue));
}
Also used : EntityProxyHandler(grails.core.support.proxy.EntityProxyHandler) ClassPropertyFetcher(org.grails.datastore.mapping.reflect.ClassPropertyFetcher)

Aggregations

EntityProxyHandler (grails.core.support.proxy.EntityProxyHandler)1 ClassPropertyFetcher (org.grails.datastore.mapping.reflect.ClassPropertyFetcher)1