Announcement Announcement Module
Collapse
No announcement yet.
Working with Entities...or not? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Working with Entities...or not?

    I am working on an application based on SOA using REST based services. The UI calls a REST based service passing it a JSON or receiving a JSON. The UI and service layers are implemented using different technologies, but can both speak "REST". We plan on using MongoDB in the backend (services layer) which is written in Java.

    My question, is... in the services layer, since I can save a doc (json) to Mongo and I need to send a json to the UI, should I convert the json to entity? or should I deal with json directly. Since I can query the json and work with json, by converting to an entity am I not tying myself to changing my entities everytime the requiremnts change? If I deal with json, I am not restricted.

    I know working with entities is easier and I have always done that in a relational model. But with UI and services communication happening via JSON and Mongo taking in (saving/querying etc) JSON directly, should I just work with JSON?

    Thank you for your suggestions/opinions

  • #2
    Personally, I would just save the JSON. If it is just a pass through from the UI down to the DB why do extra work if you don't need to.

    On the other hand, if you have to do a lot of manipulation to the json in your code and you don't have a simple API to work with it in code, then in those use cases it might be easier to use Jackson to convert your json to domain objects.

    Mark

    Comment


    • #3
      I agree and I have a mix of both...so,

      Using spring-data how can I write JSON directly to Mongo, without a mapping or conversion step. Do I have to write a custom converter?...thanks

      Comment


      • #4
        What about using the Template class? You should be able to just pass in the JSON String to it to save to the db.

        I am also curious if you can create a Repository with <String> and if that would work. But definitely through the Template. You document is the JSON String.

        Mark

        Comment


        • #5
          ok, will give it a shot and post back here

          Comment

          Working...
          X