Hi Adam,

On Wed, Jul 22, 2009 at 5:37 AM, Adam Hardy <[email protected]>wrote:

> Kevin Sutter on 21/07/09 14:42, wrote:
>
>>
>> o  In the Setter method for the proxied attribute, you must modify the
>> value
>> getting set.  In this scenario, the Calendar object was being modified in
>> the setDate method via the set() method.
>>
>
> I thought putting code in your entities' setters and getters was considered
> bad practice. Are you saying that there is much code in OpenJPA to cater for
> this kind of thing?


You are correct.  Putting code in an entity's setters and getters is not a
best practice.  But, it's not forbidden either.  OpenJPA actually logs a
warning message when this situation is detected.  But, we do not prevent
it.  Nor does the JPA spec forbid it.

This is actually one of the reasons why I didn't go forward with a patch
just yet.  Maybe the resolution will be to harden this warning message and
not allow this type of modifications in the setters if you are using
property-based access.  But, to be honest, that seems a bit harsh.  If
OpenJPA can just be a tad bit smarter when loading entities from a query
result set, then we could satisfy this request.  Even if it's not a best
practice.

Kevin


>
> Regards
> Adam
>

Reply via email to