Thanks again Didier for all the replies....

Apologies for dragging the issue out... another query (no pun
intended! :-))

1. I noticed I can avoid cloning POJOS on client and server if I place
my POJO in /shared and use an encoded string as the key and not the
Google Key... e.g.

@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
    private String encodedKey;

    @Persistent
    @Extension(vendorName="datanucleus", key="gae.pk-name",
value="true")
    private String keyName;

This seems like a simple solution to me and avoids cloning and having
to use objectify. Is there a major drawback with this method that I am
unaware of?


Question 2.

While my cloned POJOs were of type Person.java. To differentiate i
copied the complete class and called it Employee, stored it in /shared
and used the encodedKey instead of Key as above.

Strangely.... in the datastore (datastore viewer) all stored types are
of type Person. This seems very strange. Maybe I am making a simple
mistake but I can't see it.... When i run it locally, i can see the
PersistenceManage stores something of type EMployee but not the app
engine..

To investigate, i added an extra persist-able attribute to the
Employee but the object gets stored as a 'Person' and the extra
attribute is not visible.



@Override
        public String addEmployee(Employee employee) {

                System.out.println("Object made it
here!!!!!!"+employee.getFirstName());
                //Person persistentPerson = new
Person(employee.getFirstName(),employee.getLastName(),employee.getHireDate());

                DataStoreAdapter adapter = new DataStoreAdapter();
                adapter.storeEmployee(employee);

                return "Employee added....";
        }



public void storeEmployee(Employee employee) {

                Employee returnedEmployee = null;
                PersistenceManager pm = PMF.get().getPersistenceManager();

                try {
                        returnedEmployee = pm.makePersistent(employee);
                        System.out.println("STORED.......!!!!!!!!!!");
                } finally {

                        System.out.println("STORED.......!!!!!!!!!!" +
returnedEmployee.getEncodedKey()+","+returnedEmployee.getFirstName()
+", "+returnedEmployee.getHireDate()+",
"+returnedEmployee.getEncodedKey());
                        pm.close();
                }
        }


thanks again
W

On Oct 9, 4:57 am, Didier DURAND <[email protected]> wrote:
> Hi Will,
>
> I developped some mechanism based on reflection API to qutomatically
> do gets from Objectfiy pojo and sets to  client pojo when going from
> server to client and gets from client pojo to sets of  server pojo
> when going from client to server. This avoids me typing all this code
> and making errors (forgetting props; etc.)
>
> regards
> didier
>
> On Oct 8, 11:12 pm, Will <[email protected]> wrote:
>
> > Hi Guys,
>
> > [i had started with cloning client/server types so i think i'll try
> > and get this version working before refactoring to use objectify]
>
> > I was just wondering (Didier), when retrieving from datastores, how do
> > you normally deal with casting/converting your returned datastore
> > objects to the client side type..
>
> > e.g.
> > 1. client makes call to get all employees
> > 2. server retrieves all persistent Employees from Datastore .....
>
> > 3. would you convert returned objects to the GWT friendly type on the
> > server before returning them to the client?
>
> > Thanks,
>
> > On Oct 8, 8:51 pm, William Shatner <[email protected]> wrote:
>
> > > Many thanks for the replies lads...
>
> > > On Fri, Oct 8, 2010 at 18:17, David Chandler (Google) <
>
> > > [email protected]> wrote:
> > > > Have a look at GILEAD for JPA / JDO on App Engine:
> > > >http://turbomanage.wordpress.com/2009/10/15/gwt-gae-and-the-balm-of-g...
>
> > > > Also, Objectify-appengine provides emulation for Key and related
> > > > classes so that POJOs can be used with GWT.
> > > >http://code.google.com/p/objectify-appengine/
>
> > > > HTH,
> > > > --
> > > > David Chandler
> > > > Developer Programs Engineer, Google Web Toolkit
> > > > Atlanta, GA USA
>
> > > > On Oct 7, 3:19 pm, Will <[email protected]> wrote:
> > > > > Hi,
>
> > > > > I'm constructing a POJO (Employee) on teh client side and trying to
> > > > > make persistent in teh datastore.
> > > > > So that both client and sever can see this class i place it in the /
> > > > > shared folder and annotate the object as suggested by tutorials for
> > > > > persistence...
>
> > > > > @PersistenceCapable
> > > > > public class Employee {
> > > > >     @PrimaryKey
> > > > >     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > > > >     private Key key;
>
> > > > > etc.
>
> > > > > The problem as some of you are probably predicting is GWT (not Java)
> > > > > throws an exception and cannot import com.google.appengine when it
> > > > > tries to import the Key.
>
> > > > > the import com.google.appengine cannot be resolved
>
> > > > > I've seen various hacks and solutions around this  issue in this
> > > > > group, on forums and on blogs...none of which are too pretty...
>
> > > > > from super-src  hack to maintaining client and server object clones..
> > > > > (double classes) and so on...
> > > > > e.ghttp://
> > > > fredsa.allen-sauer.com/2009/04/1st-look-at-app-engine-using-jd...
>
> > > > > Does this issue still require a 'hacky' solution or is there a more
> > > > > elegant solution available now?
>
> > > > > Thanks...
>
> > > > --
> > > > 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]<google-web-toolkit%[email protected]>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-web-toolkit?hl=en.

-- 
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