Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8544079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:28:00+00:00 2026-06-11T12:28:00+00:00

I am working on Rest web services and producing JSON data for mobile app.I

  • 0

I am working on Rest web services and producing JSON data for mobile app.I am using Jersey 1.4, web server as tomcat 7, Hibernate 3.3,MySQL5.
I am new to REST world.
I have an endpoint which simply returns a list of year based on my query.

Output:

{“success”:true,”count”:2,”message”:null,”data”:[{“year”:2012},{“year”:2013}]}

which is fine what I expected.

But I have been asked to include a description value of type string with this return json data set. Based on value of year.

If year=2012(current year) description should be “this year”, for year=2013 description =”next year”, for year= 2011 description=”previous year” ,for year=2010 description=”2010″ and so on.

What I have to return is something like:
{“success”:true,”count”:2,”message”:null,”data”:[{“year”:2012,”description”:”this year”},{“year”:2013,”description”:”next year”}]

My resource class

 @GET
@Path("/{countryCd}/upcoming")
@Produces("application/json")
public  JResponse<JsonResponse> getYearsForUpcoming(@PathParam("countryCd") 
     String  countryCode) {

     JobDao jobDao =new JobDao();   
     JsonResponse res= new JsonResponse();


   @SuppressWarnings({ })
List<Jobs> jobList=  jobDao.getYearsForUpcoming(countryCode);
   if(jobList==null){
       throw new NotFoundException("Error occured! NO data found");
   }

    int count = jobList.size();
    res.setCount(count);
    res.setData(jobList);

           return JResponse.ok(res).build();

}

my query

String sql=”SELECT distinct year(s_date) as year from jobs where country=:countryCode and year(s_date)>=year(curdate()) order by year(s_date) asc”;
Query query=session.createSQLQuery(sql).addScalar(“year”).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
query.setParameter(“countryCode”, countryCode);
upcomingRegattaList= query.list();

Jobs.java ( myeclipse generated entity for table jobs )

public class Jobs implements java.io.Serializable {

private static final long serialVersionUID = 1L;
private Integer jobId;
private String status;
    private Date  SDate;
    //some more

    // getter and setters

}

I am clueless how to add a new attribute to my JSON data which is not in my entity.
Any idea greatly appreciated.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:28:02+00:00Added an answer on June 11, 2026 at 12:28 pm

    You have probably to create one more entity to map your new object that will be something like

    public class Data {
        private String year;
        private String description;
    }
    

    then load a list of this entities and add them to the response.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an app that talk to Rest web service. The JSon
I am working on a web-services data processing app and I am trying to
I am working with REST web services on a third party open source server
I am working on an app which calls a rest web service. Sometimes the
Scenario: I'm working on a web services project. It supports SOAP and REST. The
I'm working on developing some web services using RESTeasy and Seam. One of the
I'm working on a REST API and I really like the idea of using
Need help getting Ember-Data working with Zend Rest. At first, I'm familiar with Zend
I am working on a jersey rest client and I am building my client
I'm working with a REST web service that uses basic authentication and returns me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.