Hello Tim,

I'm sorry for interrupting this thread. But I need a solution.

Are you using any JPA library to get JPA to work with GWT? If not, I'll
appreciate some guide as to how you get this work, as on my side, it just
did not work as seen at
http://groups.google.com/group/google-appengine/browse_thread/thread/f1644415185bcacf/61f8dc52e75149ce?lnk=gst&q=Kayode+Odeyemi#61f8dc52e75149ce.
If you are using a library, I'll love to know about it.

On Thu, Feb 24, 2011 at 4:18 PM, David Chandler <[email protected]>wrote:

> Hi Tim,
>
> It seems like you would want to do the following within the same
> RequestFactory service method (and probably the same JPA transaction, as
> well):
>
> Persist the new Phone entity
> Persist the new Person entity
>
> Is that possible?
>
> /dmc
>
> On Thu, Feb 24, 2011 at 12:27 AM, Tim <[email protected]> wrote:
>
>> Hello all,
>>
>> I'm using GWT 2.2 and I'm trying to wrap my head around a problem that
>> seems fundamental to the combination of RequestFactory, JPA and sub-
>> entity creation.
>>
>> I have a Person entity with a @OneToMany list of Phone entity. In
>> client code, I use the editor framework to present data to the user.
>> If I want to create a new Phone entity for my Person, I use the
>> RequestContext to create a Phone proxy and attach it to the Person
>> proxy directly and send only the Person proxy to the server (since it
>> includes the new Phone proxy). On the server side, I have a method
>> that guarantees persist()ing the Phone entity before merge()ing the
>> Person entity to avoid problems with JPA.
>>
>> The problem is, the server code handling this request needs to enforce
>> some security requirements. This involves executing a query with the
>> shared EntityManager (since GWT requires a single EntityManager per
>> request). If the query is a named query or a native query, the
>> EntityManager will flush before returning the result of the query.
>> Because GWT has already fetched the existing Person entity from the
>> database and added a new, not yet persisted Phone entity to the
>> Person, JPA fails with: "During synchronization a new object was found
>> through a relationship that was not marked cascade PERSIST:
>> Phone{id=null}."
>>
>> I don't see any way to avoid this problem. RequestFactory is creating
>> the Person entity that my handler code is given. So far the only
>> solution I see is using multiple EntityManagers, one for read-write
>> operations, one for read-only. With that approach I run my named
>> queries on the read-only manager avoiding a flush on GWT-dedicated
>> EntityManager. I really don't like this idea, and since this seems
>> like a common enough setup, I'm hoping someone has encountered and
>> solved this problem.
>>
>> Any ideas?
>>
>> -Tim
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>>
>
>
> --
> David Chandler
> Developer Programs Engineer, Google Web Toolkit
> w: http://code.google.com/
> b: http://googlewebtoolkit.blogspot.com/
> t: @googledevtools
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>



-- 
Odeyemi 'Kayode O.

B.Sc(Hons) Econs, Application Developer & Systems Engineer (Sun Certified
Professional),
Oracle Certified Associate, Solaris Systems Administrator, Drupal Developer

Website: http://sinati.com <http://www.sinati.com>
Socialize with me: http://profile.to/charyorde, http://twitter.com/charyorde,

http://www.google.com/profiles/dreyemi
Skype:drecute

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to