Class has two properties of the same name



I have two classes. Now I have database access and want to get Lead value. Using Spring REST + JDBC.



@XmlRootElement(name="newlead")
public class NewLead {

private String FIRSTNAME;

private int LEADID;

public String getFIRSTNAME() {
return FIRSTNAME;
}

public void setFIRSTNAME(String FIRSTNAME) {
this.FIRSTNAME = FIRSTNAME;
}

public int getLEADID() {
return LEADID;
}

public void setLEADID(int LEADID) {
this.LEADID = LEADID;
}
}


and



@XmlRootElement(name="newLeads")
public class NewLeadList {

@XmlElement(required = true)
public List<NewLead> allLeads = new ArrayList<NewLead>();

@XmlElement(required = false)
public List<NewLead> getData() {
return allLeads;
}

public void setData(List<NewLead> data) {
this.allLeads = data;
}
}


My controller



@Controller // Will be detected by <context:component-scan>
@RequestMapping("/lead") // Will be detected by <mvc:annotation-driven> (more specifically by one of its component - RequestMappingHandlerMapping)
public class LeadController {

@Resource(name="newLeadService")
private com.varazo.service.NewLeadService newLeadService;

// This method should be called for requests to "/"
@RequestMapping(value = "/newLeads", method = RequestMethod.GET, headers="Accept=application/xml,application/json")
public @ResponseBody NewLeadList getNewLead() {
// Call service here
NewLeadList result = new NewLeadList();
result.setData(newLeadService.getAll());
System.out.println("*********************LeadController Retrieving all persons ***"+result+"***yes*************");
return result;
}


I am getting xml like



</allLeads>
<allLeads>
<LEADID>0</LEADID>
</allLeads>
<allLeads>
<LEADID>0</LEADID>
</allLeads>
<allLeads>
<LEADID>0</LEADID>
</allLeads>
<allLeads>
<LEADID>0</LEADID>
</allLeads>
<data>
<LEADID>0</LEADID>
</data>
<data>
<LEADID>0</LEADID>
</data>
<data>
<LEADID>0</LEADID>
</data>
<data>


But I need each Lead value with firstname and id values. What is the problem here?


No comments:

Post a Comment