Friday, January 27, 2012

Re: save data to database with hibernate and rpc

thanks I'm also considering that for future projects. I'm new and the first thing I learn for client-server comunication was rpc. I'm trying to learn RequestFactory and see how to integrate with hibernate. I (mm.. my boss) want to handle the data with hibernate based DAOs and Busniss Logic classes.

My GWT client code should only call methods on BL classes :

hibernate <-- DAO <-- BL <-- GWT RPC servlet <-- GWT client

In my gwt rpc based app I was able to use THE SAME model classes in all the layers, even in gwt. It can be dirty because model classes has to be putted inside gwtpackage.client.model so gwt client can translate it to javascript.

Also as I said must be careful with hibernate or other toolkits contaminating model classes. In the case of hibernate, lazy=true do the job because this obligates that collection attributes must be returned by the DAOs API (and be carefull, in the DAO, to use suported java collections supported by gwt rpc serialization).

But for small / investigation projects this gives a lot of simplicity, having no DTOs or (Request factory) Proxies.

that's my little experience so far.

regards

On Fri, 27 Jan 2012 11:30:30 -0600
Daniel Mauricio Patino León <ceo.lion.dev@gmail.com> wrote:

> I think the best way is use RequestFactory. Forguet DTO's or third party
> librarys
>
> 2012/1/27 Sebastian Gurin <sgurin@softpoint.org>
>
> > I agree with you about gilead intrusiveness. Also I see the project is not
> > mantained any more. In my case I didn't get it to work, but google's
> > using_gwt_with_hibernate.html document refer to it as a sollution. That is
> > why I recommended it.
> >
> > I will keep investigating Hibernate filter for future gwt+hibernate
> > projects. Thanks for the info.
> >
> > Regards.
> >
> > On Fri, 27 Jan 2012 00:03:06 -0300
> > Juan Pablo Gardella <gardellajuanpablo@gmail.com> wrote:
> >
> > > Instead of use gilead (to me intrusive), you can use Hibernate filter.
> > See
> > >
> > http://groups.google.com/group/google-web-toolkit/browse_thread/thread/7e46e8c33e7ee5da
> > >
> > > El 26 de enero de 2012 20:56, Sebastian Gurin <sgurin@softpoint.org
> > >escribió:
> > >
> > > > Hi I developed my web apps gwt and persist the model with hibernate.
> > You
> > > > have lot of articles about it
> > > >
> > > >
> > > >
> > http://code.google.com/intl/es-ES/webtoolkit/articles/using_gwt_with_hibernate.html
> > > >
> > > > my advice:
> > > > The main problem you will encounter is compatibility issues between
> > model
> > > > object managed by hibernate and gwt rpc java object serialization.
> > > >
> > > > Hibernate poblate your bean classes using datatypes unsupported by gwt
> > > > rpc. Gwt rpc only understand common java type implementations ( like
> > > > HashMap, HashSet ) . In particular, in many-relationships, if you
> > configure
> > > > hibernate with lazy="false" for automatically loading collection
> > > > properties, hibernate will use java.lang.Set implementation
> > unsupported by
> > > > gwt rpc serialization.
> > > >
> > > > I recommend you tu use data transfer objects (DTO) object to wrap your
> > > > real model classes.
> > > >
> > > > If you really wnt to use your existing java model directly with
> > hibernate
> > > > and gwt rpc, you have choices:
> > > >
> > > > 1) use a library like http://noon.gilead.free.fr/gilead/.
> > > > 2) do not let hibernate manage collections:
> > > > - Use lazy="true" in hiberate
> > > > - Make your DAO or BL classes API to provide with methods for
> > > > retrieving many-relations - like List<Apple> getApples(long treeId);
> > make
> > > > sure those methods return objects compatible with gwt rpc (like
> > LinkedList,
> > > > HashSet, etc)
> > > >
> > > > good look
> > > >
> > > > On Thu, 26 Jan 2012 11:32:54 -0800 (PST)
> > > > odon <odon.d.ace@gmail.com> wrote:
> > > >
> > > > > hii...
> > > > > i need help ...
> > > > > i get problem with save data to database with hibernate.
> > > > > when i executed the event, i always get on failure
> > > > > this is the code...
> > > > >
> > > > > Button btn= new Button("create");
> > > > > btn.addClickHandler(new ClickHandler() {
> > > > > public void onClick(ClickEvent event) {
> > > > > Info info= new Info();
> > > > > info.setId(null);
> > > > >
> > info.setUsername(txtbxUsername.getText());
> > > > >
> > > > info.setPassword(passwordTextBox.getText());
> > > > > infoService.saveInfo(info, new
> > > > AsyncCallback<String>() {
> > > > >
> > > > > @Override
> > > > > public void onSuccess(String
> > > > result) {
> > > > > // TODO Auto-generated
> > > > method stub
> > > > >
> > Window.alert("success");
> > > > >
> > > > > }
> > > > >
> > > > > @Override
> > > > > public void onFailure(Throwable
> > > > caught) {
> > > > > // TODO Auto-generated
> > > > method stub
> > > > > Window.alert("fail"+
> > > > caught.getMessage());
> > > > > }
> > > > > });
> > > > > }
> > > > > });
> > > > >
> > > > > how to make it on success?
> > > > > please your help :)
> > > > >
> > > > > --
> > > > > 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.
> > > > >
> > > >
> > > >
> > > > --
> > > > Sebastian Gurin <sgurin@softpoint.org>
> > > >
> > > > --
> > > > 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.
> > > >
> > > >
> > >
> > > --
> > > 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.
> > >
> >
> >
> > --
> > Sebastian Gurin <sgurin@softpoint.org>
> >
> > --
> > 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.
> >
> >
>
>
> --
> ISC. Daniel Mauricio Patiño León.
> Director ejecutivo
> Liondev S.A. de C.V.
>
> --
> 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.
>


--
Sebastian Gurin <sgurin@softpoint.org>

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