On 06-07-2010 at 12:29, Nikolaos Giannopoulos wrote:
> Unfortunately it won't work. I didn't know this previously but
> discovered that JPA by default obtains the data from the Entity
> objects via reflection NOT via its getters. What this means is that
> when the object is being persisted the getters are never called.
> Apparently the access type can be controlled in hibernate / JPA to
> use field or property access but the default is field and it is
> recommended for a number of reasons.

The way I see it, there are two possibilities:
1. The object is not persisted, meaning the property is initialized to null
   and the getter can lazily initialize it. A @PrePersist and a @PreUpdate
   event handler simply call the getter to ensure there is a value prior to
   persisting/updating it (the latter only if it can be set to null).
2. The object is persisted, meaning the property has a value (due to the
   @PrePersist event handler). In that case the field will be initialized
   correctly by the JPA provider, and the getter will recognize it only needs
   to return the value.

Am I missing something here, why such a solution cannot work?


Oscar

-- 
   ,-_
  /() ) Oscar Westra van Holthe - Kind      http://www.xs4all.nl/~kindop/
 (__ (
=/  ()  A half truth is a whole lie.  -- Yiddish Proverb

Attachment: signature.asc
Description: Digital signature

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to