Monday, September 20, 2010

Re: Using the same object at the server and client

this is a bad sign if gwt tries to compile such classes as
SessionFactory, etc.
The idea behind compilation is to produce javascript version of these
classes which I guess is not what you want.

The best way to solve this (and a bit verbose) is to use DTO or VO
objects between your gwt service (the asynch one) and business service
layers.
Business service may actually use data structure which is suitable for
particular use case rather then matching the database structure. This
way you will have control over what will be send to the client and in
what format. Decoupling gwt service from persistence framework gives
you an option to swap hibernate to say jdbc or jpa with less pain.

On Sep 18, 8:39 pm, Ketan Nale <ketann...@gmail.com> wrote:
> Hi,
>
> I am facing same proble in my application.
> I am integrating hibernate 3 in my GWT appliaction,
> but app cant find my hibernate related classes (Sessionfactory,
> Configuration) which are there in
> my hibernate3.jar.
> Give me error "did you forget to inherit a required module"
> When i searched a lot i found there is something hibernate4gwt availabe, but
> i really dont want to go with any
> other such frameworks for now.
>
> can anyone have any pointer to resolve query and integrate hibernate with
> gwt.
>
> cheers,
> ketan
>
> On 17 September 2010 17:27, AlexG <alexander.gauss.ax...@googlemail.com>wrote:
>
>
>
> > Ji Jakob,
>
> > yes this is a persisted class. The jdo-annotations, tells
> > datanucleus to persist this in the datastore.
>
> > Yea, I´m sorry but you got me right. I ran into this too, when
> > I started to work with GWT and GAE.
> > The solution is quite simple, you already said it.
> > Make a so called: "DataTransferObject" for each persisted class.
> > This is a Design Pattern .. the DTO-Pattern.
>
> > And yes, it is not a good solution.
>
> > If you have time, and good Java-knowledge you can code a
> > Code-Generator, that generates the DataTransferObjects from
> > each persisted class. It´s a good solution if you have many
> > classes, that need DTO´s. Here you can just maintain the
> > perissted class und regenerate the DTO.
>
> > I foun d a nice solution, for me:
> > I store the object (in your case DTO) in the datastore.
> > So my persistet class looks like this:
>
> > @PersitenceCapable
> > class LetterDataBaseObject
>
> > @Persistent
> > Key key;
>
> > @Persistent
> > String myID;
>
> > @Persistent(serialized = true)
> > Letter myLetter
>
> > ...
>
> > I generate a searchString, so I can still query my object.
>
> > For the beginning I would simple use the DTO-Pattern.
>
> > Greets Alex
>
> > P.S.: what about your import error?
>
> > On 17 Sep., 13:40, Janko <janko.sla...@gmail.com> wrote:
> > > Hi Alex and Thomas.
>
> > > This is really fast:D
> > > I guess the Stock.java is persisted:
> > > ---
> > > @PersistenceCapable(identityType = IdentityType.APPLICATION)
> > > public class Stock {
>
> > >   @PrimaryKey
> > >   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > >   private Long id;
> > >   @Persistent
> > >   private User user;
> > >   @Persistent
> > >   private String symbol;
> > >   @Persistent
> > >   private Date createDate;
> > > ---
>
> > > Alex if I get you right I cannot use this object on the client side?
> > > Is there another way I could move the data to client? Creating a
> > > similar class on the client side is an option, but it is a relatively
> > > bad option, because I would need to code both classes... Any ideas?
>
> > > Thank you,
> > > janko
>
> > > On Sep 17, 1:30 pm, Janko <janko.sla...@gmail.com> wrote:
>
> > > > Thank you for the quick response.
>
> > > > I now get the 13:25:23.531 [ERROR] [homework] Line 9: The import
> > > > com.google.appengine cannot be resolved
> > > > Line 9 is: import com.google.appengine.api.users.User;
>
> > > > I found I need probably inherit it... in what way? what do I need to
> > > > do?
>
> > > > On Sep 17, 1:13 pm, Brett Thomas <brettptho...@gmail.com> wrote:
>
> > > > > I think you need to move the stock class from the .server. package to
> > > > > .shared. so the client knows about it
>
> > > > > On Fri, Sep 17, 2010 at 7:09 AM, Janko <janko.sla...@gmail.com>
> > wrote:
> > > > > > PS: I get the "did you forget to inherit a required module" error..
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > Groups
> > > > > > "Google Web Toolkit" group.
> > > > > > To post to this group, send email to
> > google-web-toolkit@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to
> > > > > > google-web-toolkit+unsubscribe@googlegroups.com<google-web-toolkit%2Bunsubscribe@googlegroups.com><google-web-toolkit%2Bunsubs
> > cribe@googlegroups.com>
> > > > > > .
> > > > > > 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 google-web-toolkit@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-toolkit+unsubscribe@googlegroups.com<google-web-toolkit%2Bunsubscribe@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> Thanks and Regards,
> Ketan Nale

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

No comments:

Post a Comment