Re: Using a JPA Entity in the client

2011-06-30 Thread Juan Pablo Gardella
This side effect will fix with a filter. But I don't know how works Eclipse
Link.

2011/6/30 Jeff Larsen 

> If you return a collection in your pojo (List, Map, Set etc) those will not
> serialize correctly.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/jsDkfA1lYRkJ.
>
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Using a JPA Entity in the client

2011-06-30 Thread Jeff Larsen
If you return a collection in your pojo (List, Map, Set etc) those will not 
serialize correctly. 

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



Re: Using a JPA Entity in the client

2011-06-30 Thread Cristiano
Hello Juan,
thank you, did you find any bad side effect?

Ops! I forgot to say I use EclipseLink and GWT 2.3.0.

Cristiano




On 30 Giu, 20:49, Juan Pablo Gardella 
wrote:
> I use this approach and I preferr to RF, is more simple. But you need
> something in the middle to pass jpa classes with proxies (if you use
> Hibernate).
>
> I use the approach mentioned in this
> thread.
> No DTO, no Gilead. I will share the code soon.
>
> 2011/6/30 Cristiano 
>
>
>
>
>
>
>
> > Hello All,
>
> > While searching for instructions and best practices for using GWT and
> > JPA, I see everywhere guides suggesting to create 2 different bean
> > classes, a JPA Entity for handling on the server-side the persistence
> > on the database, and a DTO for exchange between the servlet and the
> > browser...
> > These guides suggest that GwtRpcService interface uses the DTO bean in
> > the method signature, and in the GwtRpcService implementation, the DTO
> > has to be transformed to the Entity bean so to persist it on the DB.
>
> > I have instead developed a test application where I have only one
> > single bean, placed in the client folder and annotated with JPA's
> > @Entity, and I exchange it within my RPC service interface.
> > This way it is elegant as I do not have to handle to different classes
> > and convert them, and from my test, it is simple and it seems to _be
> > working fine_.
>
> > Anyone can give me good reasons why I shouldn't follow this
> > approach?
>
> > To be noted that someone says that to follow this approach,
> > RequestFactory should be used instead of RPC service...  why?
>
> > Here the significant information about my test project:
>
> > the GWT module is net.cristcost.test.jpa.TestJpa.gwt.xml,
> > the GWT client package  () is
> > net.cristcost.test.jpa.client,
> > the bean is net.cristcost.test.jpa.client.MyBean;
> > the RPC Service interface is
> > net.cristcost.test.jpa.client.MyBeanManagerService;
> > the RPC Service implementation is
> > net.cristcost.test.jpa.server.MyBeanManagerServerImpl;
>
> > the RPC service has these two methods:
> >    public void addBean(MyBean bean);
> >    public List getBeans();
>
> > And here the relevant lines of the bean:
> > 
> > package net.cristcost.test.jpa.client;
>
> > // imports...
>
> > @Entity
> > @SuppressWarnings("serial")
> > @Table(name="my_beans", schema="jpa_test")
> > public class MyBean implements Serializable {
> >    @Id
> >    @Column(name="id")
> >    @GeneratedValue(strategy=GenerationType.IDENTITY)
> >    private Integer id;
>
> >    @Column(name="object")
> >    private String object;
>
> >    @Column(name="subject")
> >    private String subject;
>
> > // ... class continues with getter and setters ...
> > }
> > 
>
> > Thanks,
> > Cristiano
>
> > --
> > 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Using a JPA Entity in the client

2011-06-30 Thread Juan Pablo Gardella
I use this approach and I preferr to RF, is more simple. But you need
something in the middle to pass jpa classes with proxies (if you use
Hibernate).

I use the approach mentioned in this
thread.
No DTO, no Gilead. I will share the code soon.

2011/6/30 Cristiano 

> Hello All,
>
> While searching for instructions and best practices for using GWT and
> JPA, I see everywhere guides suggesting to create 2 different bean
> classes, a JPA Entity for handling on the server-side the persistence
> on the database, and a DTO for exchange between the servlet and the
> browser...
> These guides suggest that GwtRpcService interface uses the DTO bean in
> the method signature, and in the GwtRpcService implementation, the DTO
> has to be transformed to the Entity bean so to persist it on the DB.
>
>
> I have instead developed a test application where I have only one
> single bean, placed in the client folder and annotated with JPA's
> @Entity, and I exchange it within my RPC service interface.
> This way it is elegant as I do not have to handle to different classes
> and convert them, and from my test, it is simple and it seems to _be
> working fine_.
>
> Anyone can give me good reasons why I shouldn't follow this
> approach?
>
> To be noted that someone says that to follow this approach,
> RequestFactory should be used instead of RPC service...  why?
>
>
> Here the significant information about my test project:
>
> the GWT module is net.cristcost.test.jpa.TestJpa.gwt.xml,
> the GWT client package  () is
> net.cristcost.test.jpa.client,
> the bean is net.cristcost.test.jpa.client.MyBean;
> the RPC Service interface is
> net.cristcost.test.jpa.client.MyBeanManagerService;
> the RPC Service implementation is
> net.cristcost.test.jpa.server.MyBeanManagerServerImpl;
>
> the RPC service has these two methods:
>public void addBean(MyBean bean);
>public List getBeans();
>
> And here the relevant lines of the bean:
> 
> package net.cristcost.test.jpa.client;
>
> // imports...
>
> @Entity
> @SuppressWarnings("serial")
> @Table(name="my_beans", schema="jpa_test")
> public class MyBean implements Serializable {
>@Id
>@Column(name="id")
>@GeneratedValue(strategy=GenerationType.IDENTITY)
>private Integer id;
>
>@Column(name="object")
>private String object;
>
>@Column(name="subject")
>private String subject;
>
> // ... class continues with getter and setters ...
> }
> 
>
> Thanks,
> Cristiano
>
> --
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Using a JPA Entity in the client

2011-06-30 Thread Cristiano
Hello All,

While searching for instructions and best practices for using GWT and
JPA, I see everywhere guides suggesting to create 2 different bean
classes, a JPA Entity for handling on the server-side the persistence
on the database, and a DTO for exchange between the servlet and the
browser...
These guides suggest that GwtRpcService interface uses the DTO bean in
the method signature, and in the GwtRpcService implementation, the DTO
has to be transformed to the Entity bean so to persist it on the DB.


I have instead developed a test application where I have only one
single bean, placed in the client folder and annotated with JPA's
@Entity, and I exchange it within my RPC service interface.
This way it is elegant as I do not have to handle to different classes
and convert them, and from my test, it is simple and it seems to _be
working fine_.

Anyone can give me good reasons why I shouldn't follow this
approach?

To be noted that someone says that to follow this approach,
RequestFactory should be used instead of RPC service...  why?


Here the significant information about my test project:

the GWT module is net.cristcost.test.jpa.TestJpa.gwt.xml,
the GWT client package  () is
net.cristcost.test.jpa.client,
the bean is net.cristcost.test.jpa.client.MyBean;
the RPC Service interface is
net.cristcost.test.jpa.client.MyBeanManagerService;
the RPC Service implementation is
net.cristcost.test.jpa.server.MyBeanManagerServerImpl;

the RPC service has these two methods:
public void addBean(MyBean bean);
public List getBeans();

And here the relevant lines of the bean:

package net.cristcost.test.jpa.client;

// imports...

@Entity
@SuppressWarnings("serial")
@Table(name="my_beans", schema="jpa_test")
public class MyBean implements Serializable {
@Id
@Column(name="id")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;

@Column(name="object")
private String object;

@Column(name="subject")
private String subject;

// ... class continues with getter and setters ...
}


Thanks,
Cristiano

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.