I have a working OData endpoint where I can look at individual datapoints. (For example, localhost/myData/person(10) has the data of the 10th person.)
However my objects' values in my JayData javascript are not being populated. When I print:
console.log(person[10]);
Every object parameter in initData is undefined.
My full script is:
var ctx = new WebApplication.resource_dbEntities({ name: 'oData', oDataServiceHost: 'http://localhost:8080/Resource/example.svc' });
ctx.onReady(function() {
ctx.person.toArray().then(function(person){
console.log("Person[10] is:");
console.log(person[10]);
person.forEach(function(p) {
//Always prints "undefined" :(
console.log(p.person_lastname);
});
})
.fail(function(r){
console.log(r);
});
});
UPDATE: The server is most definitely sending data - see a clip from the network pannel on the webpage.
Note: I have posted additional details on the JayData forum.
I figured out the issue. Eclipse auto-generates entities from mySQL and link that to persistence.xml. The variables (even though they were private?!) in person.java did not match the initData variables.
Once I opened person.java and changed
@Column(name="project_id") private int projectId;
@Column(name="project_budget")
private int projectBudget;
@Column(name="project_client")
private String projectClient;
@Temporal(TemporalType.DATE)
@Column(name="project_enddate")
private Date projectEnddate;
@Column(name="project_ffm")
private int projectFfm;
@Column(name="project_manager")
private int projectManager;
@Column(name="project_name")
private String projectName;
@Column(name="project_number")
private String projectNumber;
@Temporal(TemporalType.DATE)
@Column(name="project_startdate")
private Date projectStartdate;
@Column(name="project_status")
private int projectStatus;
To this:
@Id
@Column(name="project_id")
private int project_id;
@Column(name="project_budget")
private int project_budget;
@Column(name="project_client")
private String project_client;
@Temporal(TemporalType.DATE)
@Column(name="project_enddate")
private Date project_enddate;
@Column(name="project_ffm")
private int project_ffm;
@Column(name="project_manager")
private int project_manager;
@Column(name="project_name")
private String project_name;
@Column(name="project_number")
private String project_number;
@Temporal(TemporalType.DATE)
@Column(name="project_startdate")
private Date project_startdate;
@Column(name="project_status")
private int project_status;
Everything worked. Thanks everyone for the help.