On Apr 12, 2007, at 8:03 PM, Dhanji R. Prasanna wrote:
>
> > When you write POJO do you mean the application data object ? As a
> > counter example, we've been working on an example that uses
> > JPA where
> > the application data objects are in the form of JPA entites. The
> > classes that contain our annotations are separate and are
> > much closer
> > to controllers in the MVC sense.
>
> This sounds like a perverted use of JPA. The POJO objects that are
> your "model" are intended to be annotated with javax.persistence
> annotations so that they can directly be mapped to the RDMBS layer.
> This is certainly how hibernate and toplink work. I am not aware
> that JPA has altered that philosophy in any way.
>
I think you might have missunderstood, our model objects *are*
annotated with JPA annotations. E.g.:
@Entity
public class Widget {
...
}
@UriTemplate("/widgets/{widgetid}")
@ProduceMime("application/widget+xml")
public class WidgetResource {
@HttpMethod
XmlWidget getWidget(@UriParam("widgetid}) String id) {
Widget w = ...
return new XmlWidget(w);
}
}
Widget is a model class using JPA, WidgetResource is a controller (a
resource) and XmlWidget is a wrapper class that is annotated with
JAXB annotations to define an XML "view" (a representation) of a Widget.
>
> IMHO, the MVC paradigm is different (with some similarities) to the
> REST
> paradigm. Instead of speaking of Controller and View, we should be
> speaking
> in terms of Resource and Representation.
>
> This is a reasonable analog. The model of course plays the same
> role in both ( i.e. entity).
>
Exactly.
Marc.
---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.
- application/pkcs7-signature attachment: smime.p7s