java - Implementing a RESTful service -


i'm building web service support android e-reader app i'm making our campus magazine. service needs return issue objects app, each of has cover image , collection of articles displayed. i'd general input on 2 strategies i'm considering, and/or specific on few issues i'm having them:

  • strategy 1: have 2 db tables, issues , articles: issues table contains int id, varchar name , varchar imageuri. articles contains many more columns (headline, content, blurb, etc.), each article on separate row. 1 of columns issueid, points issue article belongs. when issue number n requested, service first pulls data issues table , uses create new issue object. constructor instantiates new list<article> instance variable , populates pulling articles matching issueid articles table. can't figure out option how execute @ single endpoint, app has create 1 http connection needs issue (or not important think is?).

  • have single issues table id, name, , imageuri columns, plus large number of additional text article1... text article40 columns. articles packaged jsonobjects before being uploaded server, , these jsonobjects (which long) stored directly in database. worry here text files long, plus have nagging suspicion strategy isn't in line best practices (although can't put finger on why...)

also, being first web service, , given requirements specified above, advisable use spring (or other) framework or better off using jax-rs?

there 2 questions here

  1. how convert objects json , expose them rest service.
  2. how store/retrieve data.

to implement webservices, jersey favorite option. open-source reference implementation of jsr 311 (jax-rs). in addition, jersey uses jackson automatically handle json/object mapping.

to store data, second option... not option :) first solution seems viable. imho, application seems tiny, should not put in place jpa/hibernate etc.you should make 1 request hand join between issues , article, populate requested issue let jackson automatically convert object json.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -