users@jersey.java.net

Re: [Jersey] Is there a way to constrain requests mirror database requests?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 29 Jan 2009 13:48:53 +0100

Hi Eric,

It appears that you have found a bug as i too would expect the same
"owned" relationship behavior you state.

As you realize i do not have enough expertise with the code generation
to know where problem exactly resides or how to fix it. This area is
the responsibility of the Netbeans guys.

The best i can suggest is you log a bug against NetBeans using the
"rest" sub-component [1].

Paul.

[1]http://www.netbeans.org/issues/enter_bug.cgi?component=websvc

On Jan 29, 2009, at 6:39 AM, Marsh Eric wrote:

> Hello,
>
> The fact that netbeans would create RESTful services from database
> tables initially led me to believe that the database constraints
> (such as relationships between tables) would likewise constrain what
> requests could be made to the web services. As an example, I have
> two tables, people and locations. Each location references a person
> in a many to one relationship.
>
> The automatically generated code would let me request the URL .../
> peoples/{pk}/locations/{pk}. So if a person with pk=1 is referenced
> by a location with 2 and the location is "owned" by the person then
> I would expect to be able to request /peoples/1/locations/2 and when
> I do it returns the appropriate data. However I can also request /
> peoples/1/locations/25 when that location is "owned" by another
> person. I expected that the system return a 404 when that request is
> made because the underlying constraint in the database fails. I
> guess that if this was all done as a single joined select statement
> the database query would simply not return any rows. Is appears that
> the request is broken into a series of seperate queries as it is
> decomposed into different path elements and those queries need not
> correlate to each other.
>
> Part of my problem is that there is a lot of hidden source calls
> that I don't really understand so I'm having a hard time figuring
> out what's happening where. I'm responsible for writing code for a
> number of different components so I've not really had the time to
> really study the server side code and was pleased when I saw that it
> was possible to have it automatically generated. I prefer to be able
> to use the automatic code generation but it might be that I just
> have to scrap it all and write the code by hand. Mostly that's just
> going to put a road bump in my schedule.
>
> I realize that a lot of this may be issues with the netbeans guys
> rather than the Jersey/RESTful code but I don't really know who's
> responsible for what which is why I'm asking here.
>
> Also, I POSTed some XML that I thought the entity beans would
> (rightly) generate a join table row from but that didn't happen. I
> guess this means that even though the entity beans and RESTful layer
> is automatically generated from a database a lot of the relational
> information is lost along the way.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>