SamMan SamMan - 2 months ago 7
Java Question

GAE data store not returning entities

I have used objectify to query the GAE datastore i have set up that has at least one entity in it but i keep getting the following response

200 OK



  • Show headers -



{

"kind": "call#resourcesItem",
"etag": "\"AiR-q6YO1YYMgAaz-ZfT_fl7oeY/pcKQAVaDylr_ZSckRfQAxsphOUU\""

}

here is what the objectify request looks like

@ApiMethod(name = "queryCalls", path = "queryCalls", httpMethod = HttpMethod.POST)

public List<Call> queryCalls()
{
Query<Call> query = ofy().load().type(Call.class).order("name");
return query.list();


}


Call is obviously the class of the entity that is being used.

Any solutions would be most appreciated

EDIT
Here is the call class for reference

package com.cms.log;

import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;



/* Patient Entity */
@Entity
public class Call {

@Id Long callId;
@Index String patientName;
@Index String doctor;
String address1;
String address2;
String address3;
String postCode;
String patientLocation;
@Index String symptoms;
Integer contactNumber;
@Index String callDateTime;
String currentStatus;



public Call(Long callId, String patientName, String doctor, String address1,
String address2, String address3, String postCode, String patientLocation, String symptoms,
Integer contactNumber, String callDateTime, String currentStatus)
{
this.callId = callId;
this.patientName = patientName;
this.doctor = doctor;
this.address1 = address1;
this.address2 = address2;
this.address3 = address3;
this.postCode = postCode;
this.patientLocation = patientLocation;
this.symptoms = symptoms;
this.contactNumber = contactNumber;
this.callDateTime = callDateTime;
this.currentStatus = currentStatus;
};

public Long getCallId() {
return callId;
}

public void setCallId(Long Id) {
this.callId = Id;
}

public String getPatientName() {
return patientName;
}

public void setPatientName(String patientName) {
this.patientName = patientName;
}

public String getDoctor() {
return doctor;
}

public void setDoctor(String doctor) {
this.doctor = doctor;
}

public String getAddress1() {
return address1;
}

public void setAddress1(String address1) {
this.address1 = address1;
}

public String getAddress2() {
return address2;
}

public void setAddress2(String address2) {
this.address2 = address2;
}

public String getAddress3() {
return address3;
}

public void setAddress3(String address3) {
this.address3 = address3;
}

public String getPostCode() {
return postCode;
}

public void setPostCode(String postCode) {
this.postCode = postCode;
}

public String getPatientLocation() {
return patientLocation;
}

public void setPatientLocation(String patientLocation) {
this.patientLocation = patientLocation;
}

public String getSymptoms() {
return symptoms;
}

public void setSymptoms(String symptoms) {
this.symptoms = symptoms;
}

public int getContactNumber() {
return contactNumber;
}

public void setContactNumber(int contactNumber) {
this.contactNumber = contactNumber;
}

public String getCallDateTime() {
return callDateTime;
}

public void setCallDateTime(String callDateTime) {
this.callDateTime = callDateTime;
}

public String getCurrentStatus() {
return currentStatus;
}

public void setCurrentStatus(String currentStatus) {
this.currentStatus = currentStatus;
}


}

Answer

As you have highlighted in your last comment, your @Entity classes must have a no-arg constructor in order for Objectify to be able to construct objects from Datastore entities.

Once that is sorted you will be able to order your results using @Indexed properties defined in your class.

Comments