openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: Use getters/setters only
Date Tue, 16 Jun 2009 13:55:32 GMT
Hi Daryl,

On Jun 11, 2009, at 12:24 PM, Daryl Stultz wrote:

> I am using field access. I placed my annotations on the fields simply
> because I like them there. I didn't realize there was a functional
> difference. Is there any advantage/disadvantage to field vs property  
> access?
> It seems property access has the potential gotcha, while field does  
> not.
> Perhaps there is some other cost...

For me, property access should only be used with persistent abstract  
classes or persistent interfaces. In these cases, the properties are  
implemented by OpenJPA and the user has no opportunity for mischief.

In the case of non-abstract classes, IMHO using properties mixes two  
concerns: the client view (which has to use the accessors to get to  
the data) and the persistence implementation view (which has to use  
the accessors to store the data in the database). When using property  
access for non-abstract classes, you can't put business logic into the  
accessors because this interferes with the persistence  
implementation's use of the accessors.



Craig L Russell
Architect, Sun Java Enterprise System
408 276-5638
P.S. A good JDO? O, Gasp!

View raw message