On Friday, April 20, 2012 11:44:02 AM UTC+2, -sowdri- wrote:
>> For properties on proxies, you can actually simply mark them with @SkipInterfaceValidation
Actually the proxy interface is compatible with the entity. Just that for one of the values, rather then using the value in the entity, i want to make a db call to populate the value. That 's why I'm looking for the actual place where this mapping is taking place, such that I can override the default behavior only for this one entity.
>> "implement" them in a ServiceLayerDecorator.
Can you provide some more details regarding this?
class LoadFromDbServiceLayer extends ServiceLayerDecorator {
@Override
public Object getProperty(Object domainObject, String propertyName) {
if (domainObject instanceof SomeDomainObject && "someProperty".equals(propertyName)) {
// make db call and return the value
}
return super.getProperty(domainObject, propertyName);
}
}
Note that this depends on the domain type, you don't know the proxy type here (as, technically, the same domain object instance can be exposed as 2 distinct proxy instances).
If you want to depend on the proxy type instead, make it "incompatible" with the domain type (change the property name on the proxy and mark it with @SkipInterfaceValidation), so that you can check for that name in the ServiceLayerDecorator.