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.